-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Embedded IgnoreQueryFilters() propagates to parent queries #13668
Comments
|
@divega to follow up. |
@myrup one pattern you may consider using to have finer control of what filters are applied in a specific query execution is to introduce flags to shortcircuit spcific filters. The flags can be properties or fields on the DbContext. Your filters would look something like this: modelBuilder.Entity<Blog>().HasQueryFilter(b => BlogFilterDisabled || b.Tenant == TenantId);
modelBuilder.Entity<Post>().HasQueryFilter(p => PostFilterDisabled || !p.IsDeleted); Note that the flags will result in an additional Boolean parameters sent to the server for each query execution. |
@ajcvickers @divega I can absolutely work around it. I am just looking at the example code and think that it is very counterintuitive (not C# like) that the filter is applied globally instead of on the collection the method call is on. |
I was a bit surprised to find embedded IgnoreQueryFilters() calls propagates to parent queries.
Steps to reproduce
In the above code I would expect IgnoreQueryFilters to only apply to posts and not also blogs.
Further technical details
EF Core version: 2.1.2
Database Provider: PostgreSql
Operating system: Mac OS X Mojave
IDE: VS Mac 7.6.9
The text was updated successfully, but these errors were encountered: