Skip to main content

FederationDataSource.FillAsync(IEnumerable<IParameter>, String[]) Method

Populates the FederationDataSource in an asynchronous manner and passes external parameters to the data source. You can specify which queries to execute.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v24.1.dll

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


public Task FillAsync(
    IEnumerable<IParameter> sourceParameters,
    string[] queriesToFill


Name Type Description
sourceParameters IEnumerable<IParameter>

External parameters passed to the data source.

queriesToFill String[]

Queries to execute in order to populate the data source.


Type Description

A task that populates the data source.


Use this method to populate a federated data source in an individual task asynchronously. Unlike the Fill() method call, FillAsync does not lock other actions performed concurrently. For instance, the user interface remains operational while the data source is populated.

Call the FillAsync method with the await operator.

The sourceParameters parameter passes a collection of external parameters to the data source. For instance, you can pass report parameters from a reporting application and use report parameter values to filter data in the inner data sources.

The queriesToFill array specifies the names of the queries to execute in order to populate the data source.


The code sample below creates a federated data source, binds the SQL data source query’s Category parameter to the CategoryID external parameter, and populates the CategoriesProducts data member in an asynchronous manner.

using DevExpress.DataAccess;
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Excel;
using DevExpress.DataAccess.DataFederation;
using DevExpress.DataAccess.ObjectBinding;
using DevExpress.DataAccess.ConnectionParameters;
using System.IO;
using System.Threading;
// Creates and configures an SQL data source.
SqlDataSource sqlDataSource = new SqlDataSource(
    new Access97ConnectionParameters(
        "Data/nwind.mdb"), "", ""))
{ Name = "Sql_Categories" };
var categoriesQuery = SelectQueryFluentBuilder
// Binds the "Category" query parameter to the "CategoryID" external parameter.
categoriesQuery.Parameters.Add(new QueryParameter("Category", typeof(Expression), new Expression("?CategoryID")));

// Creates and configures an Excel data source.
ExcelDataSource excelDataSource = new ExcelDataSource() { Name = "Excel_Products" };
excelDataSource.FileName = "Products.xlsx";
excelDataSource.SourceOptions = new ExcelSourceOptions()
    ImportSettings = new ExcelWorksheetSettings("Sheet"),

// Creates and configures a federated data source.
FederationDataSource federationDataSource = new FederationDataSource();

Source sourceCategories = new Source(sqlDataSource.Name, sqlDataSource, "Categories");
Source sourceProducts = new Source(excelDataSource.Name, excelDataSource, "Products");

SelectNode selectNode = sourceCategories.From().Select("CategoryName")
    .Join(sourceProducts, "[Excel_Products.CategoryID] = [Sql_Categories.CategoryID]")
    .Select("CategoryID", "ProductName", "UnitPrice")

// Populates the data source's CategoriesProducts query.
await federationDataSource.FillAsync(
    new[] { new Parameter("CategoryID", typeof(System.Int32), 4) },
    new[] { "CategoriesProducts" });
See Also