Delen via


DbContextOptionsBuilder<TContext>.AddInterceptors Method

Definition

Overloads

AddInterceptors(IInterceptor[])

Adds IInterceptor instances to those registered on the context.

AddInterceptors(IEnumerable<IInterceptor>)

Adds IInterceptor instances to those registered on the context.

AddInterceptors(IInterceptor[])

Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs

Adds IInterceptor instances to those registered on the context.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> AddInterceptors (params Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor[] interceptors);
override this.AddInterceptors : Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor[] -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function AddInterceptors (ParamArray interceptors As IInterceptor()) As DbContextOptionsBuilder(Of TContext)

Parameters

interceptors
IInterceptor[]

The interceptors to add.

Returns

The same builder instance so that multiple calls can be chained.

Remarks

Interceptors can be used to view, change, or suppress operations taken by Entity Framework. See the specific implementations of IInterceptor for details. For example, 'IDbCommandInterceptor'.

Extensions can also register multiple IInterceptors in the internal service provider. If both injected and application interceptors are found, then the injected interceptors are run in the order that they are resolved from the service provider, and then the application interceptors are run in the order that they were added to the context.

Calling this method multiple times will result in all interceptors in every call being added to the context. Interceptors added in a previous call are not overridden by interceptors added in a later call.

See Using DbContextOptions and EF Core interceptors for more information and examples.

Applies to

AddInterceptors(IEnumerable<IInterceptor>)

Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs
Source:
DbContextOptionsBuilder%60.cs

Adds IInterceptor instances to those registered on the context.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> AddInterceptors (System.Collections.Generic.IEnumerable<Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor> interceptors);
override this.AddInterceptors : seq<Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function AddInterceptors (interceptors As IEnumerable(Of IInterceptor)) As DbContextOptionsBuilder(Of TContext)

Parameters

interceptors
IEnumerable<IInterceptor>

The interceptors to add.

Returns

The same builder instance so that multiple calls can be chained.

Remarks

Interceptors can be used to view, change, or suppress operations taken by Entity Framework. See the specific implementations of IInterceptor for details. For example, 'IDbCommandInterceptor'.

A single interceptor instance can implement multiple different interceptor interfaces. It will be registered as an interceptor for all interfaces that it implements.

Extensions can also register multiple IInterceptors in the internal service provider. If both injected and application interceptors are found, then the injected interceptors are run in the order that they are resolved from the service provider, and then the application interceptors are run in the order that they were added to the context.

Calling this method multiple times will result in all interceptors in every call being added to the context. Interceptors added in a previous call are not overridden by interceptors added in a later call.

See Using DbContextOptions and EF Core interceptors for more information and examples.

Applies to