EntityFramework-Extensions icon indicating copy to clipboard operation
EntityFramework-Extensions copied to clipboard

QueryHookManager needs the ability to manually add QueryHookCommandInterceptor

Open davidnemeti opened this issue 6 years ago • 1 comments

Description

It would be useful if we could indicate to QueryHookManager that we have already registered QueryHookCommandInterceptor; or it would be even better if we could manually register QueryHookCommandInterceptor by using QueryHookManager.

We have many command interceptors, and the order of them is important. E.g. one of them needs to be the last interceptor (it is a logging interceptor).

QueryHookManager's static constructor registers QueryHookCommandInterceptor at the first Hook call, which means that it will be the last interceptor, which is not good for us.

We could manually register QueryHookCommandInterceptor in our DbConfiguration by using the DbInterception.Add(new QueryHookCommandInterceptor()) statement; however, in this case QueryHookManager's static constructor would also register QueryHookCommandInterceptor, meaning that it would be registered twice.

A workaround for this if instead using DbInterception.Add(new QueryHookCommandInterceptor()) we register it implicitly by using QueryHookManager.AddOrAppendHook(Enumerable.Empty<int>().AsQueryable(), null) (the static constructor would be executed, thus the interceptor would be registered); but this is only an ugly workaround.

It would be much better if we could explicitly register the interceptor like this: QueryHookManager.RegisterQueryHookCommandInterceptor().

Further technical details

  • EF version: 6.2.0
  • EF Extensions version: 3.22.5
  • Database Provider: SQL Server

davidnemeti avatar Sep 09 '19 15:09 davidnemeti

Hello @davidnemeti ,

Thank you for reporting, we will look at it.

Best Regards,

Jonathan

JonathanMagnan avatar Sep 09 '19 20:09 JonathanMagnan