Skip to main content
All docs
V25.1
  • ReportDesignerConfigurationBuilder.RegisterDataSourceWizardMongoDBConnectionStringsProvider<T>() Method

    Registers the connection strings provider for custom MongoDB data connection.

    Namespace: DevExpress.AspNetCore.Reporting

    Assembly: DevExpress.AspNetCore.Reporting.v25.1.dll

    NuGet Package: DevExpress.AspNetCore.Reporting

    Declaration

    public ReportDesignerConfigurationBuilder RegisterDataSourceWizardMongoDBConnectionStringsProvider<T>()
        where T : class, IDataSourceWizardMongoDBConnectionStringsProvider

    Type Parameters

    Name Description
    T

    A custom connection string provider that implements the IDataSourceWizardConnectionStringsProvider interface.

    Returns

    Type Description
    ReportDesignerConfigurationBuilder

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

    Remarks

    Important

    Install the MongoDB.Driver NuGet package to work with MongoDB in the Data Source Wizard.

    A custom connection strings provider for MongoDB (that implements the IDataSourceWizardMongoDBConnectionStringsProvider interface) defines which data connections are available to users when configuring the report data source using the Data Source Wizard and Report Wizard.

    Call the RegisterDataSourceWizardMongoDBConnectionStringsProvider method at application start to register the custom connection strings provider:

    // ...
    builder.Services.ConfigureReportingServices(configurator => {
        configurator.ConfigureReportDesigner(designerConfigurator => {        
          designerConfigurator.RegisterDataSourceWizardMongoDBConnectionStringsProvider<MyDataSourceWizardConnectionStringsProvider>();
    
        });
    });
    

    The following code snippet shows a sample IDataSourceWizardMongoDBConnectionStringsProvider implementation:

    using DevExpress.DataAccess.ConnectionParameters;
    using DevExpress.DataAccess.Native;
    using DevExpress.DataAccess.Web;
    using System.Collections.Generic;
    using System.Linq;
    
    public class MyMongoDBConnectionStringsProvider : IDataSourceWizardMongoDBConnectionStringsProvider {
        public Dictionary<string, string> GetConnectionDescriptions() {
            Dictionary<string, string> connections = AppConfigHelper.GetConnections().Keys.ToDictionary(x => x, x => x);
            connections.Add("MyMongoDBConnection", "MyMongoDBConnection");
            return connections;
        }
    
        public DataConnectionParametersBase GetDataConnectionParameters(string name) {
            var mongoDBPasswordAuthInfo = new MongoDBPasswordAuthenticationInfo(
                username: "name",
                password: "password",
                authenticationDatabase: "admin"
            );
            if (name == "MyMongoDBConnection") {
                return new MongoDBConnectionParameters(
                    hostName: "localhost",
                    isSRV: true,
                    port: 27017,
                    info: mongoDBPasswordAuthInfo
                );
            }
            return AppConfigHelper.LoadConnectionParameters(name);
        }
    }
    
    See Also