Back to Devexpress

IDBConnectionInterceptor Interface

corelibraries-devexpress-dot-dataaccess-dot-sql-98452b10.md

latest4.3 KB
Original Source

IDBConnectionInterceptor Interface

Allows you to intercept operations on a connection to a database.

Namespace : DevExpress.DataAccess.Sql

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
public interface IDBConnectionInterceptor
vb
Public Interface IDBConnectionInterceptor

The following members return IDBConnectionInterceptor objects:

Remarks

Implement IDBConnectionInterceptor to intercept, modify, and/or suppress SQL operations. The list includes low-level database operations such as executing a command or setting a key-value pair in a session context. Once the connection is open, you can store values in the session context and execute any request you require.

You can register an interceptor in dashboard and report control service providers. The registration method depends on the control type and platform:

Example: BI Dashboard for ASP.NET Core - Implement Row-Level Security

This example shows how you can implement connection filtering in an application where users (tenants) share the same SQL Server user. Once the application connects to the database, it stores the current user ID in SESSION_CONTEXT. Security policies filter rows that shouldn’t be visible to this ID.

Refer to the following example for complete source code that implements the scenario listed above:

View Example

The following image displays the registration form where you can select a user to see the dashboard that displays filtered data based on your selection.

The following code snippet shows how to implement IDBConnectionInterceptor that filters data when the application connects to the database:

  1. Implement the IDBConnectionInterceptor interface (RLSConnectionInterceptor.cs in this example). When the database connection opens, store the current user ID in SESSION_CONTEXT. Modify queries to the Order table - filter data by user ID. This way you implement database behavior equivalent to connection filtering.

  2. Register the interceptor in DashboardConfigurator.

More Examples

View Example: Reporting for ASP NET.Core - Implement Row-Level Security

See Also

IDBConnectionInterceptor Members

DevExpress.DataAccess.Sql Namespace