All docs
V20.2
20.2
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.

FederationDataSource.FillAsync(String[]) Method

Populates the FederationDataSource in an asynchronous manner. You can specify which queries to execute in order to populate the data source.

Namespace: DevExpress.DataAccess.DataFederation

Assembly: DevExpress.DataAccess.v20.2.dll

Declaration

public Task FillAsync(
    string[] queriesToFill
)
Public Function FillAsync(
    queriesToFill As String()
) As Task

Parameters

Name Type Description
queriesToFill String[]

Queries to execute in order to populate the data source.

Returns

Type Description
Task

A task that populates the data source.

Remarks

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 queriesToFill array specifies the names of the queries to execute in order to populate the data source.

Example

The code sample below creates a federated data source and populates the CategoriesProducts data member in an asynchronous manner.

using System.Threading;
using System.Threading.Tasks;
using DevExpress.DataAccess;
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Excel;
using DevExpress.DataAccess.DataFederation;
using DevExpress.DataAccess.ObjectBinding;
using DevExpress.DataAccess.ConnectionParameters;
// ...
// Create and configure an SQL data source.
SqlDataSource sqlDataSource = new SqlDataSource(new Access97ConnectionParameters(Path.Combine(Path.GetDirectoryName(typeof(ReportCreator).Assembly.Location), "Data/nwind.mdb"), "", "")) { Name = "Sql_Categories" };
var CategoriesQuery = SelectQueryFluentBuilder
    .AddTable("Categories")
    .SelectAllColumnsFromTable()
    .Build("Categories");
sqlDataSource.Queries.Add(categoriesQuery);
sqlDataSource.RebuildResultSchema();

// Create and configure an Excel data source.
ExcelDataSource excelDataSource = new ExcelDataSource() { Name = "Excel_Products" };
excelDataSource.FileName = Path.Combine(Path.GetDirectoryName(typeof(Form1).Assembly.Location), "Data/Products.xlsx");
excelDataSource.SourceOptions = new ExcelSourceOptions() {
    ImportSettings = new ExcelWorksheetSettings("Sheet"),
};
excelDataSource.RebuildResultSchema();

// Create and configure 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(excelDataSource, "[Excel_Products.CategoryID] = [Sql_Categories.CategoryID]")
    .Select("CategoryID", "ProductName", "UnitPrice")
    .Build("CategoriesProducts");

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

federationDataSource.Queries.Add(selectNode);
// Populate the data source's CategoriesProducts query.
await federationDataSource.FillAsync(new[] { "CategoriesProducts" });
See Also