zzzprojects / EntityFramework.DynamicFilters

Global filtering for Entity Framework.
https://entityframework-dynamicfilters.net/
MIT License
501 stars 86 forks source link

DisableFilter is not working #140

Closed maelmahdy closed 6 years ago

maelmahdy commented 6 years ago

First of all, thanks for this great project, it really saved my day ! I've came across one issue while using it, I've a global filter named CompanyId but in a certain case, I need to disable this filter so I called DisableFilter method, however, when I ran sql profiler to capture the produced query, I can still see the filter query is included !

Here's a code snippet to show how I'm calling the api:

_context.DisableFilter("CompanyId");
var result = _context.Set<TEntity>().Where(x => !x.IsDeleted).Count(x => x.Id != currentEntityId) > 0;
_context.EnableFilter("CompanyId");
jcachat commented 6 years ago

That's normal but it will set a parameter that negates the condition. It's explained here: https://github.com/zzzprojects/EntityFramework.DynamicFilters/issues/53#issuecomment-166645862