Skip to main content

IDataSourceStorage Interface

When implemented by a class, represents a storage of the dashboard data sources.

Namespace: DevExpress.DashboardWeb

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


public interface IDataSourceStorage


To create storage of the dashboard data sources available in the Web Dashboard’s UI, call the ASPxDashboard.SetDataSourceStorage / DashboardConfigurator.SetDataSourceStorage method. You can use the in-memory storage (DataSourceInMemoryStorage) or you can implement the IDataSourceStorage interface to create a custom data source storage. Review the following topic for more information: Manage Multi-Tenancy.


Note that data sources created by end-users do not fall into IDataSourceStorage.

The following example illustrates how to configure the Dashboard control for a multi-user environment:

View Example

using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.Json;
using DevExpress.DataAccess.Sql;
using System.Web;

public class CustomDataSourceStorage : IDataSourceStorage {
    private Dictionary<string, XDocument> documents = new Dictionary<string, XDocument>();

    private const string sqlDataSourceId1 = "SQL Data Source (Northwind)";
    private const string sqlDataSourceId2 = "SQL Data Source (CarsXtraScheduling)";
    private const string jsonDataSourceId = "JSON Data Source";

    public CustomDataSourceStorage() {
        DashboardSqlDataSource sqlDataSource1 = new DashboardSqlDataSource(sqlDataSourceId1, "NorthwindConnectionString");
        SelectQuery query1 = SelectQueryFluentBuilder
        SelectQuery query2 = SelectQueryFluentBuilder

        DashboardSqlDataSource sqlDataSource2 = new DashboardSqlDataSource(sqlDataSourceId2, "CarsXtraSchedulingConnectionString");
        SelectQuery query = SelectQueryFluentBuilder

        DashboardJsonDataSource jsonDataSource = new DashboardJsonDataSource(jsonDataSourceId);
        jsonDataSource.JsonSource = new UriJsonSource(new Uri(""));
        jsonDataSource.RootElement = "Customers";

        documents[sqlDataSourceId1] = new XDocument(sqlDataSource1.SaveToXml());
        documents[sqlDataSourceId2] = new XDocument(sqlDataSource2.SaveToXml());
        documents[jsonDataSourceId] = new XDocument(jsonDataSource.SaveToXml());

    public XDocument GetDataSource(string dataSourceID) {
        if (GetDataSourcesID().Contains(dataSourceID)) {
            return documents[dataSourceID];
        else {
            throw new ApplicationException("You are not authorized to use this datasource.");

    public IEnumerable<string> GetDataSourcesID() {
        var userName = (string)HttpContext.Current.Session["CurrentUser"];

        if (userName == "Admin") {
            return documents.Keys;
        else if (userName == "User") {
            return new string[] { sqlDataSourceId2 };
        else {
            return new string[0];

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the IDataSourceStorage interface.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also