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
Add Counting Functionality to Docs #135
Comments
I wouldn't say it's a base feature since the users don't define anything explicitly in the specification. The specification infrastructure enables this feature but ultimately is utilized by the repository implementation. Description:
public virtual IQueryable<T> GetQuery<T>(IQueryable<T> query, ISpecification<T> specification, bool evaluateCriteriaOnly = false) where T : class
{
var evaluators = evaluateCriteriaOnly ? this.evaluators.Where(x => x.IsCriteriaEvaluator) : this.evaluators;
foreach (var evaluator in evaluators)
{
query = evaluator.GetQuery(query, specification);
}
return query;
}
Ultimately, the users don't have to do anything. They're not forced to define a separate specification just for Count, but they can keep using the same specification, and the rest will be handled by the library. Calling
|
So does that mean that if I have a specification that uses some of these operations for the actual query logic and not just pagination, this strategy wouldn't work? Like if I had something like this: public class PlayersThatAreNotTheBest: Specification<Players>
{
public PlayersThatAreNotTheBest(int skip, int take)
{
Query
.OrderByDescending(p => p.Goals)
.Skip(5)
//paging
Query
.Skip(skip)
.Take(take)
}
} Now I know there are easy workarounds to this. For instance in my example you could make the query be for ALL players, ordered by goals, and make the caller specify the "skip 5" as part of his pagination logic on the first call. But I'm just using it for illustration purposes. I'm just wondering if we shouldn't document explicitly the fact that if the users want to use the I'm brand new to this library so I'm still putting the pieces together. I have a few problems in figuring out how to best document all this. That behavior could be documented at the method level, but the problem is that it is tied to the specific EF implementations of At any rate, if we leave things as is, the only thing that makes sense to me is to document the behavior of |
See: #134 (comment)
@fiseni do you think this would be considered a 'base feature'?
https://ardalis.github.io/Specification/features/base-features.html
If not where should we describe it? Usage?
The text was updated successfully, but these errors were encountered: