The Query DbSetFilter is the old filter API for Entity Framework 6 (EF6) before the code switched to use Interceptor instead.
The feature revamp was done in 2016 to support include and LazyLoading but have also some limitation such as performance and instance filter that the old code didn’t have.
- DO NOT Support include
- DO NOT Support lazy loading
To make both features live together, method in Query DbSetFilter has been renamed to add prefix with DbSet before Filter.
EF+ Query Filter Global
Global filter can be used by any context.
Global filter is normally preferred in most scenario over instance filter since the filter code is centralized in one method over being spread in multiple methods.
Use entities context constructor to initialize global filter by default.
EF+ Query Filter By Instance
Instance filter applies filters to the current context only. The filtering logic is added once the context is created.
Use entities context constructor to make some filter “global” to all context.
EF+ Query Filter By Query
Query filter applies filters to specific queries only. The filtering logic is added globally or by instance but in a disabled state and then it is enabled by these specific queries.
EF+ Query Filter By Inheritance/Interface
Filter can be enabled and disabled by class inheritance and interface.
EF+ Query Filter Enable/Disable
Filters are very flexible, you can enable and disable them at any time and only for a specific inheritance or interface if desired.
EF+ Query Filter AsNoFilter
You can bypass all filters by using AsNoFilter method in a query if a special scenario doesn’t require filtering.