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.v21.2.Win.dll

NuGet Package: DevExpress.Win.Dashboard

Declaration

[Browsable(false)]
[DefaultValue(null)]
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.

View Example

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

namespace Dashboard_CustomSchemaProvider {
    // 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 supplierIdColumn = new DBColumn { Name = "SupplierID" };
                    table.AddColumn(supplierIdColumn);
                    DBColumn productNameColumn = new DBColumn { Name = "ProductName" };
                    table.AddColumn(productNameColumn);

                    DBForeignKey foreignKey1 = new DBForeignKey(
                        new[] { categoryIdColumn },
                        "Categories",
                        CustomDBSchemaProvider.CreatePrimaryKeys("CategoryID"));
                    table.ForeignKeys.Add(foreignKey1);
                    DBForeignKey foreignKey2 = new DBForeignKey(
                        new[] { supplierIdColumn },
                        "Suppliers",
                        CustomDBSchemaProvider.CreatePrimaryKeys("SupplierID"));
                    table.ForeignKeys.Add(foreignKey2);
                }
                if (table.Name == "Suppliers" && table.Columns.Count == 0) {
                    DBColumn supplierIdColumn = new DBColumn { Name = "SupplierID" };
                    table.AddColumn(supplierIdColumn);
                    DBColumn companyNameColumn = new DBColumn { Name = "CompanyName" };
                    table.AddColumn(companyNameColumn);
                }
            }
        }

        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.Contains("nwind.mdb")) {
                if (tables != null) {
                    return tables;
                }

                tables = new DBTable[3];
                tables[0] = new DBTable("Categories");
                tables[1] = new DBTable("Products");
                tables[2] = new DBTable("Suppliers");
            }
            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