All docs
V20.1
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

UnionNodeBuilder Class

Provides a Fluent interface method to build a union query.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v20.1.dll

Declaration

public class UnionNodeBuilder
Public Class UnionNodeBuilder

Remarks

Use the Union(QueryNode, QueryNode) method to access the UnionNodeBuilder's object and build a query with a Fluent API.

Examples

The following code snippet demonstrates how to use UnionType to create a federated data source from two Excel files. The UnionNodeBuilder's Fluent API is used to construct a federated query.

The QueryBuildingExtensions.Union(QueryNode, QueryNode, UnionType) method combines rows from two queries into a single data set and removes duplicate rows.

The result is a new "UnionTable" query that combines the two queries.

using DevExpress.DataAccess.DataFederation;
using DevExpress.DataAccess.Excel;
using System.Linq;

//...

static ExcelDataSource CreateExcelDataSource(string fileName, string worksheetName) {
  var excelDataSource = new ExcelDataSource {
      FileName = fileName,
      SourceOptions = new ExcelSourceOptions {
          SkipEmptyRows = true,
          SkipHiddenColumns = true,
          SkipHiddenRows = true,
          ImportSettings = new ExcelWorksheetSettings { WorksheetName = worksheetName }
      }
  };
    return excelDataSource;
}

public static FederationDataSource CreateFederationDataSource() {
    Source salesPerson1 = new Source("SalesPerson", CreateExcelDataSource("../../../SalesPerson.xlsx", "Data"));
    Source salesPerson2 = new Source("SalesPerson2", CreateExcelDataSource("../../../SalesPerson.xlsx", "Data2"));
    var query =
        salesPerson1.From().Select("CategoryName", "Country", "Sales Person", "OrderDate", "OrderID", "Discount", "Extended Price").Build()
        .Union(
            salesPerson2.From().Select("CategoryName", "Country", "Sales Person", "OrderDate", "OrderID", "Discount", "Extended Price").Build(),
            UnionType.Union
        )
        .Build("UnionTable");
    FederationDataSource federation = new FederationDataSource();
    federation.Queries.Add(query);
    federation.Fill();
    return federation;
}

Inheritance

Object
UnionNodeBuilder
See Also