Pagination Should be after OrderBy #746
Mutahhar758
started this conversation in
General
Replies: 1 comment 1 reply
-
A specification is the "definition" of the query. This is separate from its execution. It doesn't matter where the orderby is called. It will always apply to the whole query. The execution of the query is done by the specificationevaluator which will always apply the "where" (and "search") first, then the "orderby" and then the "pagination". (See https://github.com/ardalis/Specification/blob/6a3dfd5f1064c49217295b7d141c1f8f91680ef6/Specification.EntityFrameworkCore/src/Ardalis.Specification.EntityFrameworkCore/Evaluators/SpecificationEvaluator.cs#L23-L39) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
In the pagination SpecificationBuilderExtensions. I have seen that OrderBy is applied after the pagination but I don't think it is the right way to do pagination. It means It is sorting only in the current page records.
See line number 33 to 35.
https://github.com/fullstackhero/dotnet-webapi-boilerplate/blob/8d05f1537aefed2ac5c80d51a10e0c8dfb73a802/src/Core/Application/Common/Specification/SpecificationBuilderExtensions.cs#L16-L36
Regards,
Mutahhar.
Beta Was this translation helpful? Give feedback.
All reactions