Skip to main content

UnionNode Class

A node that provides data with a Union and UnionAll queries.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v24.1.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap

Declaration

public class UnionNode :
    QueryNode

The following members return UnionNode objects:

Remarks

The main part of the Federated Data Source is the FederationDataSourceBase.Queries collection that contains federated queries.

You can create federated queries of the following types:

  • Join

    Combines rows from two or more tables based on a column they share. The join type specifies records that have matching values in both tables. In API, create the SelectNode instance.

  • Union and Union All

    The Union query combines rows from two or more tables into one data set and removes duplicate rows in merged tables. The UnionAll query operates like Union, but duplicates rows from different tables when they contain the same data. You can only create a union query for data sources that contain columns with the same name. Data types of such columns should be implicitly converted. In API, create the UnionNode instance and specify UnionNode.Type as Union/UnionAll.

  • Transformation

    If a data source contains a complex column (an object), you can transform its properties to display them as separate columns in a flattened view. If one of the data columns is an array, you can unfold its values and display a new data row for every element of the array. When you unfold the column, you can flatten it and create a flattened view. In API, create the TransformationNode instance.

Add the UnionNode objects to the FederationDataSourceBase.Queries collection to use the created query in a federated data source.

The following code shows how to create Union and UnionAll queries and combine two Excel data sources:

private static FederationDataSource CreateFederatedDataSourceUnion(SqlDataSource sqliteDataSource, ExcelDataSource exceldataSource) {
    FederationDataSource federationDS = new FederationDataSource();
    Source sqlSource = new Source("sqlite", sqliteDataSource, "SQLite Orders");
    Source excelSource = new Source("excel", exceldataSource);

    UnionNode queryUnionAll = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite")
        .UnionAll(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel"))
        .Build("OrdersUnionAll");

    UnionNode queryUnion = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite")
        .Union(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel"))
        .Build("OrdersUnion");


    federationDS.Queries.Add(queryUnionAll);
    federationDS.Queries.Add(queryUnion);

    federationDS.Fill(new DevExpress.Data.IParameter[0]);
    return federationDS;
}

Inheritance

See Also