Extract Data Source

  • 2 minutes to read

This tutorial shows how to add the DashboardExtractDataSource to data source storage and make it available to users.

  1. In your application, create the Data folder and add the SalesOverview.dat file to it from the C:\Users\Public\Documents\DevExpress Demos 20.2\Components\Data folder.

  2. In the Startup.cs file, create a public method that returns the configured dashboard's data source storage (DataSourceInMemoryStorage) and define the Extract data source.

    using DevExpress.DashboardCommon;
    
    public DataSourceInMemoryStorage CreateDataSourceStorage() {
        DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
    
        DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource("Extract Data Source");
        extractDataSource.Name = "Extract Data Source";
        extractDataSource.FileName = Path.Combine(HostingEnvironment.ContentRootPath, @"Data\SalesOverview.dat");
        dataSourceStorage.RegisterDataSource("extractDataSource ", extractDataSource.SaveToXml());
    
        return dataSourceStorage;
    }
    
    NOTE

    Use the IHostingEnvironment.ContentRootPath property to set the absolute path to the directory that contains the Extract data source.

  3. Use the DashboardConfigurator.SetDataSourceStorage method to set the data source storage and pass the created CreateDataSourceStorage method to use the return value as a parameter.

    using DevExpress.AspNetCore;
    using DevExpress.DashboardAspNetCore;
    using DevExpress.DashboardWeb;
    
    public void ConfigureServices(IServiceCollection services) {            
        services
            .AddMvc()
            .AddDefaultDashboardController(configurator => {
                // ...
                configurator.SetDataSourceStorage(CreateDataSourceStorage());
            });
    }
    

    The Extract Data Source is now available in the Web Dashboard:

web-dashboard-ex-extract-data-source

Users can now bind dashboard items to data in the Web Dashboard's UI.

Example

The example shows how to make a set of data sources available for users in the Web Dashboard application.

View Example: How to Register Data Sources for ASP.NET Core Dashboard Control