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

Refactor specification expressions #185

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

devbased
Copy link
Contributor

Closes #182.

…ecs (for in-memory evaluators); minor cleanup
@ardalis ardalis merged commit 9e8c7eb into ardalis:main Dec 13, 2021
@fiseni
Copy link
Collaborator

fiseni commented Dec 13, 2021

Thanks @devbased, it looks great.

Now that we refactored the types in ISpecification, can you please revise the evaluators in the plugin packages (EFCore and EF6) too? For instance, we might not need the Select here. You can refactor the input of the Search extension method too. There is Order evaluator in EF6 too.

namespace Ardalis.Specification.EntityFrameworkCore
{
    public class SearchEvaluator : IEvaluator
    {
        private SearchEvaluator() { }
        public static SearchEvaluator Instance { get; } = new SearchEvaluator();

        public bool IsCriteriaEvaluator { get; } = true;

        public IQueryable<T> GetQuery<T>(IQueryable<T> query, ISpecification<T> specification) where T : class
        {
            foreach (var searchCriteria in specification.SearchCriterias.GroupBy(x => x.SearchGroup))
            {
                var criterias = searchCriteria.Select(x => (x.Selector, x.SearchTerm));
                query = query.Search(criterias);
            }

            return query;
        }
    }
}

@fiseni
Copy link
Collaborator

fiseni commented Dec 13, 2021

Ok, Steve was faster than me :) My bad, I noticed these details after approving the PR.
@devbased would you like to make those changes in an additional PR?

@ardalis
Copy link
Owner

ardalis commented Dec 13, 2021

Sorry! I was going to just approve but then thought "why should I make Fati have to come back and merge it..."

@fiseni
Copy link
Collaborator

fiseni commented Dec 13, 2021

No big deal. Everything works, it's more of cleanup work. We can do it in an additional PR.

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 this pull request may close these issues.

Improving specification evaluation performance
3 participants