Skip to main content

JoinElement Class

Defines the JOIN clause.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v24.1.dll

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

Declaration

public class JoinElement

Remarks

The SelectNode.SubNodes property provides access to a collection of JoinElement objects.

Example

This code snippet demonstrates how to create a query that combnes two tables from different data sources with the JOIN clause.

Note

The complete sample project How to Create a Federated Data Source at Runtime is available in the DevExpress Examples repository.

using DevExpress.DataAccess.DataFederation;
// ...
    FederationDataSource federation = new FederationDataSource();

    Source sourceProducts = new Source("Products", CreateSqlDataSource(), "Products");
    Source sourceOrderDetail = new Source("OrderDetail", CreateExcelDataSource("SalesPerson.xlsx", "Data"));

    var sourceNodeProducts = new SourceNode(sourceProducts, "Products");
    var sourceNodeOrderDetail = new SourceNode(sourceOrderDetail, "OrderDetail");

    var query = new SelectNode(sourceNodeProducts)
    {
        Alias = "ProductsOrderDetail",
        SubNodes = {
                new JoinElement {
                    Node = sourceNodeOrderDetail,
                    Condition = $"[{sourceNodeProducts.Alias}.ProductName] == [{sourceNodeOrderDetail.Alias}.ProductName]"
                }
            },
        Expressions = {
            new SelectColumnExpression(sourceNodeProducts, "ProductName"),
            new SelectColumnExpression(sourceNodeProducts, "QuantityPerUnit"),
            new SelectColumnExpression(sourceNodeOrderDetail, "OrderID"),
            new SelectColumnExpression(sourceNodeOrderDetail, "OrderDate"),
            new SelectColumnExpression(sourceNodeOrderDetail, "Quantity"),
            new SelectColumnExpression(sourceNodeOrderDetail, "UnitPrice")
            }
    };
    federation.Queries.Add(query);
    federation.Fill();

Inheritance

Object
JoinElement
See Also