Skip to main content

QueryBuildingExtensions.From(Source) Method

Provides access to the SelectNodeBuilder object used to build a query with a Fluent interface.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v24.1.dll

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

Declaration

public static SelectNodeBuilder From(
    this Source source
)

Parameters

Name Type Description
source Source

A Source object for which a query is being built.

Returns

Type Description
SelectNodeBuilder

A SelectNodeBuilder object that implements a Fluent interface to build a query.

Remarks

The Source.From extension method allows you to use a Fluent API to build a query.

Example

This code snippet demonstrates how to create a federated data source that contains two queries. The SelectNodeBuilder‘s Fluent API is used to construct a federated query.

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"));
    Source sourceHeader = new Source("OrderHeader", CreateExcelDataSource("OrderHeaders.xlsx", "OrderHeader"));


    SelectNode query1 = sourceProducts.From().Select("ProductName", "QuantityPerUnit", "UnitsInStock")
        .Join(sourceOrderDetail, "[Products.ProductName] = [OrderDetail.ProductName]")
        .Select("OrderDate")
        .Build("ProductsOrderDetail");

    SelectNode query2 = sourceHeader.From().Select("OrderID", "Status", "Description")
        .Join(sourceOrderDetail, "[OrderHeader.OrderID] = [OrderDetail.OrderID]")
        .Select("Quantity", "Extended Price")
        .Build("OrderHeaderOrderDetail");

    federation.Queries.AddRange(new[] { query1, query2 });
    federation.Fill()
See Also