The requested page is not available for the requested platform. You are viewing the content for Default platform.
All docs
19.2 (EAP/Beta)
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

How to: Bind ASP.NET MVC Dashboard to a Federated Data Source

  • 4 min to read

This example demonstrates how to create a Federated data source and add it to the Web Dashboard data source list.

In this example, the DashboardFederationDataSource class is used to supply data obtained from the federated query.

This example uses the DevExpress.DataAccess.DataFederation.SelectNodeBuilder object to create a federated query. It involves the following steps:

  1. Create the Source object for each data source integrated in the federated data source.

  2. Use the Source.From extension method to access the SelectNodeBuilder and create a SelectNode object.

  3. Add the SelectNode object to the FederationDataSourceBase.Queries collection as a federated query.


The complete sample project ASP.NET MVC Dashboard - How to Bind a Dashboard to a Federated Data Source Created at Runtime is available in the DevExpress Examples repository.

using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DashboardWeb.Mvc;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.DataFederation;
using DevExpress.DataAccess.Excel;
using DevExpress.DataAccess.Sql;
using System.Web.Hosting;
using System.Web.Routing;

namespace MVC_DataFederationExample
    public static class DashboardConfig
        public static void RegisterService(RouteCollection routes)

            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            DashboardConfigurator.PassCredentials = true;

            // Uncomment this string to allow end users to create new data sources based on predefined connection strings.
            //DashboardConfigurator.Default.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());

            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            // Registers an SQL data source.
            SQLiteConnectionParameters sqliteParams = new SQLiteConnectionParameters();
            sqliteParams.FileName = HostingEnvironment.MapPath(@"~/App_Data/nwind.db");

            DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQLite Data Source", sqliteParams);
            SelectQuery selectQuery = SelectQueryFluentBuilder
                .Build("SQLite Orders");
            dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());

            // Registers an Object data source.
            DashboardObjectDataSource objDataSource = new DashboardObjectDataSource();
            objDataSource.Name = "ObjectDS";
            objDataSource.DataSource = DataGenerator.Data;

            dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml());

            // Registers an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("ExcelDS");
            excelDataSource.FileName = HostingEnvironment.MapPath(@"~/App_Data/SalesPerson.xlsx");
            excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Data"));
            dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

            // Registers the Federated data source.
            DashboardFederationDataSource federationDataSource = new DashboardFederationDataSource("Federated Data Source");
            Source sqlSource = new Source("sqlite", sqlDataSource, "SQLite Orders");
            Source excelSource = new Source("excel", excelDataSource, "");
            Source objectSource = new Source("SalesPersonDS", objDataSource, "");
            SelectNode mainQueryCreatedByNodeBuilder =
                .Select("OrderDate", "ShipCity", "ShipCountry")
                .Join(excelSource, "[excel.OrderID] = [sqlite.OrderID]")
                    .Select("CategoryName", "ProductName", "Extended Price")
                    .Join(objectSource, "[SalesPersonDS.SalesPerson] = [excel.Sales Person]")
                        .Select("SalesPerson", "Weight")
            federationDataSource.CalculatedFields.Add("FDS", "[Weight] * [Extended Price] / 100", "Score");
            federationDataSource.Fill(new DevExpress.Data.IParameter[0]);
            dataSourceStorage.RegisterDataSource("federatedDataSource", federationDataSource.SaveToXml());

            DashboardConfigurator.Default.DataLoading += DataLoading;

        private static void DataLoading(object sender, DataLoadingWebEventArgs e)
            if (e.DataSourceName == "ObjectDS")
                e.Data = DataGenerator.CreateSourceData();