The requested page is not available for the requested platform. You are viewing the content for Default platform.

ReportDesignerConfigurationBuilder.RegisterDataSourceWizardConfigurationConnectionStringsProvider(IConfigurationSection) Method

Registers connection strings to display in the SQL Data Source Wizard based on a custom configuration.

Namespace: DevExpress.AspNetCore.Reporting

Assembly: DevExpress.AspNetCore.Reporting.v18.2.dll

Declaration

public ReportDesignerConfigurationBuilder RegisterDataSourceWizardConfigurationConnectionStringsProvider(
    IConfigurationSection connectionStringsConfigurationSection
)
Public Function RegisterDataSourceWizardConfigurationConnectionStringsProvider(
    connectionStringsConfigurationSection As IConfigurationSection
) As ReportDesignerConfigurationBuilder

Parameters

Name Type Description
connectionStringsConfigurationSection IConfigurationSection

A configuration object that combines connection strings from different sources.

Returns

Type Description
ReportDesignerConfigurationBuilder

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

Remarks

To enable end-users to create new data sources in the Web Report Designer, you should register connection strings explicitly. The SQL Data Source Wizard displays these connections.

Use the RegisterDataSourceWizardConfigurationConnectionStringsProvider method to provide the Report Designer with connection strings from a set of different configuration sources:

  1. Create a custom configuration and load connection strings from all the required sources. For instance, create the ConfigurationBuilder class instance and use its extension methods (AddJson, AddInMemoryCollection, etc.) See Configuration in ASP.NET Core for more information.

    using System.Collections.Generic;
    using Microsoft.Extensions.Configuration;
    
    public IConfigurationSection GetConnectionStrings() {
      var connectionStrings = new Dictionary<string, string> {
        [$"ConnectionStrings:VehiclesInMemory"] = "XpoProvider=SQLite;Data Source=Data/vehicles.db",
        [$"ConnectionStrings:CarsInMemory"] = "XpoProvider=SQLite;Data Source=Data/cars.db;"
      };
      return new ConfigurationBuilder()
        .SetBasePath(hostingEnvironment.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
        .AddJsonFile($"appsettings.{hostingEnvironment.EnvironmentName}.json", optional: true)
        .AddInMemoryCollection(connectionStrings)
        .Build()
        .GetSection("ConnectionStrings");
    }
    
  2. Call the RegisterDataSourceWizardConfigurationConnectionStringsProvider method at application startup after the AddDevExpressControls method call.

    using DevExpress.AspNetCore;
    using DevExpress.AspNetCore.Reporting;
    using Microsoft.Extensions.DependencyInjection;
    
    public void ConfigureServices(IServiceCollection services) {
        services.AddDevExpressControls();
        services.ConfigureReportingServices((builder) => {
            builder.ConfigureReportDesigner(designer => {
                designer.RegisterDataSourceWizardConfigurationConnectionStringsProvider(GetConnectionStrings());
            });
        });
    }
    

You can also use the static DefaultConnectionStringProvider.AssignConnectionStrings method to register specific connection strings globally. These connection strings are available for the Report Designer's Preview to fill a report's data source and generate the resulting document. The SQL Data Source Wizard does not use these global strings if you registered strings at the Report Designer level.

See Register Data Connections for more information.

See Also