Skip to main content
A newer version of this page is available. .

DashboardDesigner.CustomDBSchemaProviderEx Property

Allows you to specify a custom schema for the SQL Data Source.

Namespace: DevExpress.DashboardWin

Assembly: DevExpress.Dashboard.v19.2.Win.dll

Declaration

[DefaultValue(null)]
[Browsable(false)]
public IDBSchemaProviderEx CustomDBSchemaProviderEx { get; set; }

Property Value

Type Default Description
IDBSchemaProviderEx *null*

An object that implements the IDBSchemaProviderEx interface that provides a custom schema.

Example

This example demonstrates how to customize a data store schema for a dashboard data source that uses a connection to the Northwind database.

In this example, the IDBSchemaProviderEx interface is implemented by a class that defines a custom data store schema containing two related tables. The IDBSchemaProviderEx.GetTables method returns tables and columns which will be included to a data store schema.

To see the result, add a new query or edit the existing query.

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.Xpo.DB;
using DevExpress.XtraBars.Ribbon;
using System.Collections.Specialized;

namespace Dashboard_CustomSchemaProvider {
    public partial class Form1 : RibbonForm {
        public Form1() {
            InitializeComponent();
            dashboardDesigner1.CreateRibbon();

            // Specifies a custom schema provider.
            dashboardDesigner1.CustomDBSchemaProviderEx = new CustomDBSchemaProvider();

            // Loads a dashboard from an XML file.
            dashboardDesigner1.LoadDashboard(@"..\..\Data\dashboard.xml");
        }

        // Creates a new class that defines a custom data store schema by implementing the 
        // IDBSchemaProvider interface.
        class CustomDBSchemaProvider : IDBSchemaProviderEx {
            DBTable[] tables;
            public void LoadColumns(SqlDataConnection connection, params DBTable[] tables) {
                foreach(DBTable table in tables) {
                    if(table.Name == "Categories" && table.Columns.Count == 0) {
                        DBColumn categoryIdColumn = new DBColumn { Name = "CategoryID" };
                        table.AddColumn(categoryIdColumn);
                        DBColumn categoryNameColumn = new DBColumn {Name = "CategoryName"};
                        table.AddColumn(categoryNameColumn);
                    }
                    if(table.Name == "Products" && table.Columns.Count == 0) {
                        DBColumn categoryIdColumn = new DBColumn { Name = "CategoryID" };
                        table.AddColumn(categoryIdColumn);
                        DBColumn productNameColumn = new DBColumn {Name = "ProductName"};
                        table.AddColumn(productNameColumn);

                        DBForeignKey foreignKey = new DBForeignKey(
                            new[] { categoryIdColumn },
                            "Categories",
                            CustomDBSchemaProvider.CreatePrimaryKeys("CategoryID"));
                        table.ForeignKeys.Add(foreignKey);
                    }
                }
            }

            public static StringCollection CreatePrimaryKeys(params string[] names) {
                StringCollection collection = new StringCollection();
                collection.AddRange(names);
                return collection;
            }

            public DBTable[] GetTables(SqlDataConnection connection, params string[] tableList) {
                var cp = connection.ConnectionParameters as Access97ConnectionParameters;
                if (cp != null && cp.FileName == @"..\..\Data\nwind.mdb") {
                    if (tables != null) {
                        return tables;
                    }
                    tables = new DBTable[2];

                    DBTable categoriesTable = new DBTable("Categories");
                    tables[0] = categoriesTable;

                    DBTable productsTable = new DBTable("Products");
                    tables[1] = productsTable;                  
                }
                else
                    tables = new DBTable[0];
                return tables;
            }

            public DBTable[] GetViews(SqlDataConnection connection, params string[] viewList) {
                DBTable[] views = new DBTable[0];
                return views;
            }

            public DBStoredProcedure[] GetProcedures(SqlDataConnection connection, params string[] procedureList) {
                DBStoredProcedure[] storedProcedures = new DBStoredProcedure[0];
                return storedProcedures;
            }
        }
    }
}

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

Note

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