Skip to content

FeatureRequest: IgnoreQueryFilters #159

Closed

Description

@rezathecoder

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

Activity

  1. fiseni commented on Sep 20, 2021

    @fiseni
    Collaborator

    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.

  2. ardalis commented on Sep 20, 2021

    @ardalis
    Owner

    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.

  3. Codibex commented on Oct 15, 2021

    @Codibex

    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.

  4. fiseni commented on Dec 2, 2021

    @fiseni
    Collaborator

    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);
    }
  5. added this to the 6.0 milestone on Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions