Skip to main content
All docs
V25.1
  • IDataSourceWizardConnectionStringsStorage Interface

    When implemented by a class, represents a storage of data connections used in the Dashboard Data Source Wizard.

    Namespace: DevExpress.DashboardWeb

    Assembly: DevExpress.Dashboard.v25.1.Web.dll

    NuGet Package: DevExpress.Web.Dashboard.Common

    Declaration

    public interface IDataSourceWizardConnectionStringsStorage :
        IDataSourceWizardConnectionStringsProvider

    Remarks

    The following code snippet shows how to save the created connection strings in the the ASP.NET Core dashboard application.

    View Example: Dashboard for ASP.NET Core - How to create new JSON data sources at runtime

    Implement the IDataSourceWizardConnectionStringsStorage interface to use it as a place where to save the newly created connection strings:

    using DevExpress.DashboardWeb;
    
    public class ConnectionStringProvider: IDataSourceWizardConnectionStringsStorage {
        readonly Dictionary<string, DataConnectionParametersBase> storage = new Dictionary<string, DataConnectionParametersBase>();
        public Dictionary<string, string> GetConnectionDescriptions() {        
            return storage.ToDictionary(p=>p.Key, p=>p.Key);
        }
    
        public DataConnectionParametersBase GetDataConnectionParameters(string name) {
            return storage[name];
        }
    
        public void SaveDataConnectionParameters(string name, DataConnectionParametersBase connectionParameters, bool    saveCredentials) {
            storage[name] = connectionParameters;
        }
    }
    

    Use the created class instance as the SetConnectionStringsProvider‘s parameter so users can reuse the connections and create new JSON data sources at runtime:

    using DevExpress.DashboardWeb;
    using DevExpress.DataAccess.Web;
    using DevExpress.DataAccess.ConnectionParameters;
    using System.Linq;
    
    var builder = WebApplication.CreateBuilder(args);
    
    builder.Services.AddDevExpressControls();
    builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
        DashboardConfigurator configurator = new DashboardConfigurator();
        configurator.SetConnectionStringsProvider(new ConnectionStringProvider());
        // ...
        return configurator;
    });
    
    var app = builder.Build();
    
    See Also