DbConfiguration.AddInterceptor(IDbInterceptor) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从派生自 DbConfiguration 类的构造函数调用此方法,以在应用程序启动时注册 IDbInterceptor 。 请注意,也可以使用任何时间 DbInterception添加和删除拦截器。
protected internal void AddInterceptor(System.Data.Entity.Infrastructure.Interception.IDbInterceptor interceptor);
member this.AddInterceptor : System.Data.Entity.Infrastructure.Interception.IDbInterceptor -> unit
Protected Friend Sub AddInterceptor (interceptor As IDbInterceptor)
参数
- interceptor
- IDbInterceptor
要注册的侦听器。
注解
此方法作为一种方便且可发现的方法来向 Entity Framework 添加配置。 在内部,它的工作方式与使用 AddDependencyResolver 添加适当的解析程序 IDbInterceptor相同。 这意味着,如果需要,可以使用自定义解析程序或由 Inversion-of-Control 容器支持的解析程序来实现相同的功能。