Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registered IDbCommandInterceptor's do not run #244

Closed
ghost opened this issue Aug 15, 2022 · 2 comments
Closed

Registered IDbCommandInterceptor's do not run #244

ghost opened this issue Aug 15, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 15, 2022

Hi, I've noticed that after Query is converted via ToLinqToDB, the IDbCommandInterceptor registered will not be run, is there a way to resolve that? We're currently using DbCommandInterceptor to append sp_set_session_context to each query

@ghost ghost changed the title IDbCommandInterceptor do not run Registered IDbCommandInterceptor's do not run Aug 15, 2022
@plukawski
Copy link
Contributor

plukawski commented Dec 22, 2022

Its an expected behavior - the IDbCommandInterceptor is an Ef Core interceptor type. Linq2Db uses its own interceptor types. You have to register Linq2Db interceptors in order for interceptors to work after converting query to Linq2Db. Look at InterceptorTests class (https://github.com/linq2db/linq2db.EntityFrameworkCore/blob/e4d2abcb3cbeda79d6056530e9f5cd6daeba304c/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/InterceptorTests.cs) for an examples of how to accomplish this.
Especially look at the UseEfCoreRegisteredInterceptorsIfPossible extension used in these tests - it allows to register EF Core interceptor classes for Linq2Db as long as they implement both EF Core and Linq2Db interceptor interfaces,

@MaceWindu
Copy link
Contributor

Closing as anwered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants