$skip is not applied when $orderby is not defined
See original GitHub issueI’ve encountered issue when using standalone $skip parameter, for example corebuilding?$skip=2
I think problem lies in GetQueryableMethod
method:
if (orderByClause == null)
{
return Expression.Call
(
expression.Type.IsIQueryable() ? typeof(Queryable) : typeof(Enumerable),
"Take",
new[] { type },
expression,
Expression.Constant(top.Value)
);;
}
So, if OrderByClause
is not defined, only Take
expression is going to be returned, without applying Skip
expression.
Before starting with the fix, could you tell me if this is actually a bug, or intended behavior. To me, it looks like the bug.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:18 (11 by maintainers)
Top Results From Across the Web
c# - How to solve "The method 'Skip' is only supported for ...
The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'."...
Read more >Can't use take and skip alongside order by in querybuilder ...
I noticed that in all the queries I try to do that involve any type of join , the orderBy statement can't be...
Read more >False positive "Skip/Take without OrderBy" when using ...
When using .UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery) we get a the following warning The query uses a row limiting ...
Read more >ORDER BY Clause (Transact-SQL) - SQL Server
The ORDER BY clause does not guarantee ordered results when these constructs are queried, unless ORDER BY is also specified in the query...
Read more >SQL Order by Clause overview and examples
It does not skip the next value in rank if we have multiple rows with similar values. The NTILE function divides the complete...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, so currently I’m generating a default order for the following cases:
orderby
isnull
butskip
is notnull
orderby
isnull
buttop
is notnull
orderby
isnull
but bothtop
andskip
are notnull
I agree with you about using the same method for generating an order, keep things consistent. I’ll start on creating such a method and go from there.
That’s a good point point regarding
Top
. Do we not want to apply the same rules? Maybe we should.With regard to generating an
OrdeyBy
, the algorithm itself does not matter - better to use the same one in both cases.Two ways to go:
Here’s an example of some code getting the first literal type.
I like the 2nd option better. You’d be calling
MemberInfo.GetCustomAttributes()
to see ifSystem.ComponentModel.DataAnnotations.KeyAttribute
has been applied (if there is no Id property).So if
GenerateStableOrder
is not available for both cases I would just create a new method which does the same thing.