Skip to main content

SqlDataSource.FillAsync() Method

Populates the SqlDataSource in an asynchronous manner.

Namespace: DevExpress.DataAccess.Sql

Assembly: DevExpress.DataAccess.v24.1.dll

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

Declaration

public Task FillAsync()

Returns

Type Description
Task

A task that populates the data source.

Remarks

Use this method to populate an SQL 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.

All queries are validated one by one. If any validation errors occur, an AggregateException is thrown with these errors. Use the exception’s InnerExceptions property to access a collection of QueryExecutionException objects (use their InnerException property to access an actual ValidationException).

If the validation succeeds, all queries are executed one by one. If any errors occur, an AggregateException is thrown with these errors. Use the exception’s InnerExceptions property to access a collection of QueryExecutionException objects (use their InnerException property to access an actual DevExpress.DataAccess.Native.Sql.SqlExecutionException).

To validate and execute only specific queries, use a FillAsync method overload that accepts the queriesToFill parameter.

Example

The code sample below creates an SqlDataSource and populates it in an asynchronous manner.

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
SqlDataSource DataSource { get; set; }
public void CreateSqlDataSource()
{
    MsSqlConnectionParameters connectionParameters = new MsSqlConnectionParameters(
        ".", "NorthWind", null, null, MsSqlAuthorizationType.Windows);
    var sqlDataSource = new SqlDataSource(connectionParameters) { Name = "Sql_Categories" };
    var categoriesQuery = SelectQueryFluentBuilder
        .AddTable("Categories")
        .SelectAllColumnsFromTable()
        .Build("Categories");
    categoriesQuery.Name = "queryCategoriesAllFields";
    sqlDataSource.Queries.Add(categoriesQuery);
    sqlDataSource.RebuildResultSchema();
    DataSource = sqlDataSource;
}
async void FillDataSourceAsyncAllQueries()
{
    await DataSource.FillAsync();
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the FillAsync() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also