Skip to main content

ReportDesignerConfigurationBuilder.RegisterSqlDataSourceWizardCustomizationService<T>() Method

Registers a service for validating custom SQL queries specified in the Data Source Wizard.

Namespace: DevExpress.AspNetCore.Reporting

Assembly: DevExpress.AspNetCore.Reporting.v24.1.dll

NuGet Package: DevExpress.AspNetCore.Reporting


public ReportDesignerConfigurationBuilder RegisterSqlDataSourceWizardCustomizationService<T>()
    where T : ISqlDataSourceWizardCustomizationService

Type Parameters

Name Description

Custom SQL queries validation service that implements the ISqlDataSourceWizardCustomizationService interface.


Type Description

A ReportDesignerConfigurationBuilder that can be used to further configure the Report Designer services.


By default, the Data Source Wizard does not allow end users to specify custom SQL queries. To enable this functionality, call the EnableCustomSql() method in the application’s startup.

Custom SQL queries are validated before their execution. Although the default validation mechanism only allows custom queries containing SELECT statements (except for SELECT INTO clauses), it cannot be considered safe as it does not prevent execution of potentially harmful requests. For this reason, we strongly recommend that you provide your own validation logic that does not reduce the default restrictions and permits only execution of specific query kinds. To define a custom validation logic, implement the ICustomQueryValidator interface. To apply this logic for custom SQL queries, implement an ISqlDataSourceWizardCustomizationService service and register it using the RegisterSqlDataSourceWizardCustomizationService method.

The following code demonstrates how define and register a custom service for validating custom SQL queries.

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Wizard.Services;
using DevExpress.DataAccess.Web;
// ... 

public class MyCustomValidator : ICustomQueryValidator {
    public bool Validate(DataConnectionParametersBase connectionParameters, string sql, ref string message) {
        // Add your custom validation logic here. 
        // The method should return true if the query is valid and false otherwise. 

public class CustomSqlDataSourceWizardCustomizationService : ISqlDataSourceWizardCustomizationService {
    public ICustomQueryValidator CustomQueryValidator {
        get { return new MyCustomValidator(); }

    public bool IsCustomSqlDisabled {
        get { return false; }

Note that the ISqlDataSourceWizardCustomizationService interface exposes the IsCustomSqlDisabled property. Make this property read-only and set it to false. This enables you to specify custom SQL queries in the Create a Query or Select a Stored Procedure page of the SQL Data Source Wizard. In this instance, you don’t have to use the EnableCustomSql method, which is useful when you don’t have to implement a custom validation logic.

See Also