Skip to main content
All docs
V24.2

IDBCommandInterceptor Interface

Allows you to intercept commands sent to a relational database.

Namespace: DevExpress.DataAccess.Sql

Assembly: DevExpress.DataAccess.v24.2.dll

Declaration

public interface IDBCommandInterceptor

Remarks

Dashboard and report controls execute a variety of SQL statements against the database. Implement IDBCommandInterceptor to intercept these data source commands. You can suppress a command or modify the execution algorithm.

You can register interceptors in service providers of dashboard or report controls. The registration method depends on the control type and platform:

Example: Reporting for WinForms - Override the Default Isolation Level

The following example shows how to override the default isolation level (READ COMMITTED) in a specific query. The change allows users to retrieve information without being locked by another process that modifies the same data. This way, the query consumes less memory.

View Example

  1. Implement the IDBCommandInterceptor interface (NolockInterceptor.cs in this example). Call the IDBCommandInterceptor.CommandCreated(String, IDbCommand) method and specify CommandText to execute.
using DevExpress.DataAccess.Sql;
using System.Data;

namespace XtraReportApp {
    internal class NolockInterceptor : IDBCommandInterceptor {
        public void CommandCreated(string queryName, IDbCommand command) {
            command.CommandText += " WITH (NOLOCK)";
        }
    }
}
  1. Call the XRDesignMdiController.AddService method to register the interceptor.
using DevExpress.DataAccess.Sql;
using System;

namespace XtraReportApp {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {
            InitializeComponent();
            reportDesigner1.AddService(typeof(IDBCommandInterceptor), new NolockInterceptor());
        }
        private void Form1_Load(object sender, EventArgs e) {
            reportDesigner1.OpenReport(new XtraReport1());
        }
    }
}
See Also