The requested page is not available for the requested platform. You are viewing the content for Default platform.

Connect the ASP.NET Core Dashboard to an OLAP data source

  • 2 min to read

The example below shows how to add the DashboardOlapDataSource to the data source storage and make it available to end users.

  1. In the Startup.cs file, create a public method that returns a configured in-memory dashboard data source storage (DataSourceInMemoryStorage) and define the OLAP data source. OLAP mode supports only XML for Analysis (XMLA) with MSMDPUMP. Use the DashboardOlapDataSource.OlapDataProvider static property to specify the XMLA data provider.

    using DevExpress.DashboardCommon;
    using DevExpress.DashboardWeb;
    
    public DataSourceInMemoryStorage CreateDataSourceStorage() {
        DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
    
        DashboardOlapDataSource olapDataSource = new DashboardOlapDataSource("OLAP Data Source", "olapConnection");
        DashboardOlapDataSource.OlapDataProvider = OlapDataProviderType.Xmla;
        dataSourceStorage.RegisterDataSource("olapDataSource", olapDataSource.SaveToXml());    
    
        return dataSourceStorage;
    }
    
  2. Call the DashboardConfigurator.SetDataSourceStorage method to configure the data source storage. Use the created CreateDataSourceStorage method as the SetDataSourceStorage parameter. Then subscribe to the DashboardConfigurator.ConfigureDataConnection event to pass the connection parameters the OLAP data source requires.

    using DevExpress.AspNetCore;
    using DevExpress.DashboardAspNetCore;
    using DevExpress.DashboardWeb;
    
    public void ConfigureServices(IServiceCollection services) {            
        services
            .AddMvc()
            .AddDefaultDashboardController(configurator => {
                // ...
                configurator.SetDataSourceStorage(CreateDataSourceStorage());
                configurator.ConfigureDataConnection += Configurator_ConfigureDataConnection;
            });
    }
    
  3. Provide the required connection parameters at runtime in the DashboardConfigurator.ConfigureDataConnection event handler.

    using DevExpress.DataAccess.ConnectionParameters;
    
    private void Configurator_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
        if (e.ConnectionName == "olapConnection") {
            OlapConnectionParameters olapParams = new OlapConnectionParameters();
            olapParams.ConnectionString = "Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;"
                + "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;";
            e.ConnectionParameters = olapParams;
        }
    }
    
  4. As a result, the OLAP Data Source is displayed as a Web Dashboard's predefined data source.

    End users can now bind the dashboard items to data in the Web Dashboard's UI. See Binding Dashboard Items to Data in the Web Dashboard's UI for more information.

Example

The example displays how to provide a Web Dashboard with a set of predefined data sources available for end users.