Skip to main content
All docs
V25.1
  • SqlDataSource.FillAsync(String[]) Method

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

    Namespace: DevExpress.DataAccess.Sql

    Assembly: DevExpress.DataAccess.v25.1.dll

    NuGet Package: DevExpress.DataAccess

    Declaration

    public Task FillAsync(
        string[] queriesToFill
    )

    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 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.

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

    All queries listed in the queriesToFill parameter 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 listed 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).

    Example

    The code sample below creates an SqlDataSource and populates the queryCategoriesAllFields data member 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 FillDataSourceAsync()
    {
        await DataSource.FillAsync(new string[] { "queryCategoriesAllFields" });
    }
    
    See Also