Skip to main content
A newer version of this page is available. .

JsonDataSource.FillAsync(IEnumerable<IParameter>) Method

Populates the JsonDataSource in an asynchronous manner and uses the sourceParameters parameter to pass external parameters to the data source.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v20.2.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.WindowsDesktop.DataAccess

Declaration

public Task FillAsync(
    IEnumerable<IParameter> sourceParameters
)

Parameters

Name Type Description
sourceParameters IEnumerable<IParameter>

External parameters passed to the data source.

Returns

Type Description
Task

A task that populates the data source.

Remarks

Use this method to populate a JSON 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 specify the JsonDataSource‘s PathParameters, QueryParameters, or HeaderParameters.

Handle the FillError event, or catch the JsonDataSourceException exception, to process the case when the FillAsync method failed to populate the data source.

Example

The code sample below is a reporting application that uses JsonDataSource to provide data to a report. The data source is populated with data in an asynchronous manner. The FileNameParameter report parameter is passed to the data source to specify the endpoint file name.

using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Parameters;
using DevExpress.DataAccess;
using DevExpress.DataAccess.Json;
// ...
// JsonDataSource is used to provide data to an XtraReport class instance.
XtraReport report = new XtraReport();
report.Parameters.Add(new Parameter() {
    Name = "FileNameParameter",
    Type = typeof(string),
    Value = "customers.json"
});
// Create a new JSON source.
var jsonSource = new UriJsonSource() {
    Uri = new Uri(@"https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/")
};
jsonSource.PathParameters.Add(
    // The "FileName" path parameter uses the external "FileNameParameter" parameter value.
    new PathParameter("FileName", typeof(Expression), new Expression("?FileNameParameter"))
);
// Assign the JSON source to the data source.
var datasource = new JsonDataSource() {
    JsonSource = jsonSource
};
await datasource.FillAsync(report.Parameters);
See Also