Back to Devexpress

Register a Custom Schema Provider for a Synonym Database

xtrareports-117273-feature-guide-to-devexpress-reports-bind-reports-to-data-sql-database-register-a-custom-schema-provider-for-a-synonym-database.md

latest8.7 KB
Original Source

Register a Custom Schema Provider for a Synonym Database

  • Feb 18, 2026
  • 4 minutes to read

This document describes how to implement a custom data source schema provider that enables end-users to bind reports to a synonym database.

Tip

A synonym is a database object that provides an alternative name for another database object.

Refer to the Oracle and Microsoft SQL Server documentation to learn how different database engines support synonyms.

Implement a Custom Schema Provider

The following code shows how to create a custom database schema provider inherited from the DBSchemaProviderEx class that is the IDBSchemaProviderEx interface’s default implementation.

csharp
using DevExpress.DataAccess.Sql;
using DevExpress.Xpo.DB;
using System.Collections.Generic;
using System.Linq;
// ...

public class SynonymDBSchemaProvider : DevExpress.DataAccess.Sql.DBSchemaProviderEx {
    public override DBTable[] GetTables(SqlDataConnection connection, params string[] tableList) {
        List<DBTable> tables = base.GetTables(connection, tableList).ToList();
        if(connection.Name == "OracleConnection")
            tables.Add(new DBTable("Regions") {
                Columns = {
                    new DBColumn { Name = "REGION_ID", ColumnType = DBColumnType.Int32 },
                    new DBColumn { Name = "REGION_NAME", ColumnType = DBColumnType.String, Size = 25 },
                }
            });

        return tables.ToArray();
    }
}
vb
Imports DevExpress.DataAccess.Sql
Imports DevExpress.Xpo.DB
Imports System.Collections.Generic
Imports System.Linq
' ...

Public Class SynonymDBSchemaProvider
    Inherits DevExpress.DataAccess.Sql.DBSchemaProviderEx
    Public Overrides Function GetTables(connection As SqlDataConnection, ParamArray tableList As String()) As DBTable()
        Dim tables As List(Of DBTable) = MyBase.GetTables(connection, tableList).ToList()
        If connection.Name = "OracleConnection" Then
            tables.Add(New DBTable("Regions") With { _
                Key .Columns = {New DBColumn() With { _
                    Key .Name = "REGION_ID", _
                    Key .ColumnType = DBColumnType.Int32 _
                }, New DBColumn() With { _
                    Key .Name = "REGION_NAME", _
                    Key .ColumnType = DBColumnType.[String], _
                    Key .Size = 25 _
                }} _
            })
        End If

        Return tables.ToArray()
    End Function
End Class

Register the Schema Provider in a WinForms Reporting Application

The following code registers a custom database schema provider in a WinForms End-User Report Designer by calling the XRDesignMdiController.AddService method.

csharp
using DevExpress.DataAccess.Sql;
using DevExpress.XtraReports.UserDesigner;
// ...

public partial class Form1 : XRDesignRibbonForm {
    public Form1() {
        InitializeComponent();
        DesignMdiController.AddService(typeof(IDBSchemaProviderEx), new SynonymDBSchemaProvider());
    }
}
vb
Imports DevExpress.DataAccess.Sql
Imports DevExpress.XtraReports.UserDesigner
' ...

Public Class Form1
    Inherits XRDesignRibbonForm

    Public Sub New()
        InitializeComponent()
        DesignMdiController.AddService(GetType(IDBSchemaProviderEx), New SynonymDBSchemaProvider())
    End Sub

End Class

Register the Schema Provider in a WPF Reporting Application

The following code registers a custom database schema provider in a WPF End-User Report Designer.

xml
<Window x:Class="CustomDBSchemaProviderEx.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CustomDBSchemaProviderEx"
        xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner" 
        xmlns:dxda="http://schemas.devexpress.com/winfx/2008/xaml/dataaccess" 
        xmlns:dasql="clr-namespace:DevExpress.DataAccess.Sql;assembly=DevExpress.DataAccess.v18.1" 
        Title="MainWindow" >

    <dxrud:ReportDesigner HorizontalAlignment="Left" VerticalAlignment="Top">
        <dxrud:ReportDesigner.ServicesRegistry>
            <dxda:InstanceEntry ServiceType="{x:Type dasql:IDBSchemaProviderEx}" >
                <dxda:InstanceEntry.Instance>
                    <local:SynonymDBSchemaProvider />
                </dxda:InstanceEntry.Instance>
            </dxda:InstanceEntry>
        </dxrud:ReportDesigner.ServicesRegistry>
    </dxrud:ReportDesigner>

</Window>

Register the Schema Provider in an ASP.NET Reporting Application

Create a custom database schema provider factory by implementing the IDataSourceWizardDBSchemaProviderExFactory interface as shown below. Use the IDataSourceWizardDBSchemaProviderExFactory.Create method to initialize a new custom data store schema provider ( SynonymDBSchemaProvider ).

csharp
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Web;
// ...

public class MyDataSourceWizardDBSchemaProviderFactory : IDataSourceWizardDBSchemaProviderExFactory {
    public IDBSchemaProviderEx Create() {
        return new SynonymDBSchemaProvider();
    }
}
vb
Imports DevExpress.DataAccess.Sql
Imports DevExpress.DataAccess.Web
' ...

Public Class MyDataSourceWizardDBSchemaProviderFactory
    Implements IDataSourceWizardDBSchemaProviderExFactory
    Public Function Create() As IDBSchemaProviderEx Implements IDataSourceWizardDBSchemaProviderExFactory.Create
        Return New SynonymDBSchemaProvider()
    End Function
End Class

ASP.NET Application

Register the custom database schema provider factory by calling the static DefaultReportDesignerContainer.RegisterDataSourceWizardDBSchemaProviderExFactory<T> method, as shown below.

csharp
using DevExpress.DataAccess.Web;
using System;
// Add a reference to the DevExpress.XtraReports.Web assembly
using DevExpress.XtraReports.Web.ReportDesigner
// ...

public class Global_asax : System.Web.HttpApplication {
    void Application_Start(object sender, EventArgs e) {
        // ...
        // Register the custom provider factory.
        DefaultReportDesignerContainer.RegisterDataSourceWizardDBSchemaProviderExFactory<MyDataSourceWizardDBSchemaProviderFactory>();
    }
    // ...
}
vb
Imports DevExpress.DataAccess.Web
Imports System
' Add a reference to the DevExpress.XtraReports.Web assembly
Imports DevExpress.XtraReports.Web.ReportDesigner
' ...

Public Class Global_asax
    Inherits System.Web.HttpApplication
    Private Sub Application_Start(sender As Object, e As EventArgs)
        ' ...
        ' Register the custom provider factory.
        DefaultReportDesignerContainer.RegisterDataSourceWizardDBSchemaProviderExFactory(Of MyDataSourceWizardDBSchemaProviderFactory)()
    End Sub
    ' ...
End Class

ASP.NET Core Application

Register the custom database schema provider factory by calling the RegisterDataSourceWizardDBSchemaProviderExFactory<T>() method, as shown below.

csharp
using DevExpress.AspNetCore;
using DevExpress.AspNetCore.Reporting;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDevExpressControls();
builder.Services.ConfigureReportingServices(configurator => {
    configurator.ConfigureQueryBuilder(queryBuilderConfigurator => {
        // Register the custom provider factory.
        queryBuilderConfigurator.RegisterDataSourceWizardDBSchemaProviderExFactory<MyDataSourceWizardDBSchemaProviderFactory>();
    });
});

var app = builder.Build();