Back to Devexpress

IDataSourceWizardConnectionStringsStorage Interface

dashboard-devexpress-dot-dashboardweb-a0e43884.md

latest3.4 KB
Original Source

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.2.Web.dll

NuGet Package : DevExpress.Web.Dashboard.Common

Declaration

csharp
public interface IDataSourceWizardConnectionStringsStorage :
    IDataSourceWizardConnectionStringsProvider
vb
Public Interface IDataSourceWizardConnectionStringsStorage
    Inherits 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:

cs
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:

cs
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

IDataSourceWizardConnectionStringsStorage Members

Customize the Dashboard Data Source Wizard

Dashboard Data Source Wizard

DevExpress.DashboardWeb Namespace