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

FeatureRequest: IgnoreQueryFilters #159

Closed
rezathecoder opened this issue Sep 19, 2021 · 4 comments · Fixed by #191
Closed

FeatureRequest: IgnoreQueryFilters #159

rezathecoder opened this issue Sep 19, 2021 · 4 comments · Fixed by #191
Milestone

Comments

@rezathecoder
Copy link

Hi
If we have global filters applied in ef core configuration there should be a way to ignore them in some specifications.

@fiseni
Copy link
Collaborator

fiseni commented Sep 20, 2021

We've been trying hard not to make the package too EF centric. But, we've added AsNoTracking, AsNoTrackingWithIdentityResolutionEvaluator, AsSplitQueryEvaluator. So, I assume we can add this one too, it's useful one.

@ardalis
Copy link
Owner

ardalis commented Sep 20, 2021

Agreed. As much as possible it's nice to put them in the EF-specific packages, but I know that's not always possible, either.

@Codibex
Copy link

Codibex commented Oct 15, 2021

I implemented this by myself. I derive from Specification and use an evaluator. The new specificaton class is a base class from that I can derive my business specifications. It was very easy for me.

But I was suprised that the SpecificationEvaluator has no ctor to add my new evaluator to the default ones. So I had to copy the whole list from the default ctor. I think no one would loose the default evaluators.

@fiseni
Copy link
Collaborator

fiseni commented Dec 2, 2021

Note to implement IgnoreQueryFilters in the next release.

Regarding your question, the SpecificationEvaluator has 2 constructors, parameterless one and the one accepting a list of evaluators. There is no ctor that accepts a single evaluator (to be appended to the default ones), and that's done intentionally. The order of evaluation might be important, and we simply wouldn't know where to place your evaluator (it would be a guessing game). So, yeah you have to pass the whole list 😄 Just copy-paste stuff from the default evaluator and add yours.

public SpecificationEvaluator()
{
	this.evaluators.AddRange(new IEvaluator[]
	{
		WhereEvaluator.Instance,
		SearchEvaluator.Instance,
		IncludeEvaluator.Instance,
		OrderEvaluator.Instance,
		PaginationEvaluator.Instance,
		AsNoTrackingEvaluator.Instance,
#if NETSTANDARD2_1
		AsSplitQueryEvaluator.Instance,
		AsNoTrackingWithIdentityResolutionEvaluator.Instance
#endif
	});
}
public SpecificationEvaluator(IEnumerable<IEvaluator> evaluators)
{
	this.evaluators.AddRange(evaluators);
}

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

Successfully merging a pull request may close this issue.

4 participants