-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Filters not applied when using dbcontext's generic set method #47
Comments
Hello @catalintoma , Which version of Entity Framework are you using? For EF6, since version 1.4.x, EF+ Query Filter should support everything including set. For EF5, this will be probably never be supported. For EF Core, this will be eventually supported when EF Core will support Interceptor like EF6 do. |
Hello, Can you give me some info about what is different between calling the property and the set method? |
For EF6, Interceptor is used, so it allows us to support everything like Include method, Lazy loading, Set, etc. For EF5 && EF Core, The expression is directly modified at DbSet level. What that means is only LINQ using directly the context and the set are filtered. Every time you create a new context and enable filters, we change all expression from all DbSet in the context for the filtered expression. However, the Set method create a new DbSet ServiceProviderServiceExtensions.GetRequiredService<IDbSetInitializer>(this.InternalServiceProvider))).CreateSet<TEntity>(this) I will wait till EF team release the version 1.1 before checking this issue since they may do some Lifecycle hooks change which may allow to support this feature like we do for EF6: Lifecycle hooks |
Hi, The filter is not applied. Can you help me ? |
Hello @deliotomaz , Try to create your own issue, it makes easier to answer & follow request I have answered your question here: #87 |
Any update here? I am also using generic context.Set()... and cannot make it work. |
Hello @cindoum , Are you using EF Core? If yes, there is nothing I can do automatically since Interceptor is not yet supported. However, I could maybe add an extension method "SetFiltered" or something similar as a temporary fix. context.SetFiltered<Customer>.Where(....); Do you believe it's a good idea or you have a better one? Best Regards, Jonathan |
Thanks for your answer. Yes i am using Ef core! For now, there is no way of having filter for multi tenancy nor soft delete using ef core? Thats kind of strange. If you have an idea on how this can be implemented using context.SetFiltered instead of context.Set that would be working, then i would love to see it. For me, it does not seem to be a problem as a workaround while the interceptor is implemented... |
great! looking forward to test it! Thanks
Le lun. 9 janv. 2017 19:42, Jonathan Magnan <[email protected]> a
écrit :
… Hello @cindoum <https://github.com/cindoum> ,
The v1.4.21 is available.
The SetFiltered extensions method is now available but only work on type
that is part of a DbSet or has been registered (See #87
<#87>)
Best Regards,
Jonathan
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#47 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACRuKCoPRnCiVzBfH5SqhOmYsf7TUaTfks5rQtPhgaJpZM4J-RVK>
.
|
For example, in this case
dbContext.Filter<Company>(q => q.Where(c => c.Name == "abc"));
dbContext.Set<Company>().ToList();
The filter will not be applied.
There are already consumers of a context that use the generic method (UserManager for example)
In my case the fix was to override the set method and just forward the call to the property using reflection.
Basically, transformed from dbContext.Set to dbContext.Companies;
The text was updated successfully, but these errors were encountered: