Skip to main content
All docs
V24.1

IReportDesignerModelBuilder.DataSources(IDictionary<String, Object>) Method

Registers data sources so that they are available in Web Report Designer when you edit reports.

Namespace: DevExpress.XtraReports.Web.ReportDesigner.Services

Assembly: DevExpress.XtraReports.v24.1.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

Declaration

IReportDesignerModelBuilder DataSources(
    IDictionary<string, object> dataSources
)

Parameters

Name Type Description
dataSources IDictionary<String, Object>

A data source dictionary where the key is the name of the data source and the value is an instance of the data source.

Returns

Type Description
IReportDesignerModelBuilder

A IReportDesignerModelBuilder that can be used to further configure the Report Designer.

Remarks

The following code example is the controller Action that registers data sources for use in the Web Report Designer:

[HttpPost("[action]")]
public async Task<IActionResult> GetDesignerModel(
    [FromForm] string reportName,
    [FromServices] IReportDesignerModelBuilder reportDesignerModelBuilder) {
    var dataSources = new Dictionary<string, object>();
    var ds = new SqlDataSource("NWindConnectionString");

    // Create a SQL query to access the Products data table.
    SelectQuery query = SelectQueryFluentBuilder.AddTable("Products").SelectAllColumnsFromTable().Build("Products");
    ds.Queries.Add(query);
    ds.RebuildResultSchema();
    dataSources.Add("Northwind", ds);

    reportName = string.IsNullOrEmpty(reportName) ? "TestReport" : reportName;
    var designerModel = await reportDesignerModelBuilder
        .Report(reportName)
        .DataSources(dataSources)
        .BuildModelAsync();

    return DesignerModel(designerModel);
}

For more information, review the following help topic: Data Sources in Web End-User Report Designer (ASP.NET Core).

See Also