You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an ordering requirement that I can't feasibly represent using OData, so my intent is to order the IQueryable before calling GetQueryAsync.
This works if I don't use OData $skip or $top, but if either of those are specified then the custom ordering is overridden by the GetQueryableMethod > GetDefaultOrderByCall call.
I've tried doing the .OrderBy call after .GetQueryAsync, however if the expression used for my custom order includes navigation properties/children that aren't selected/expanded in the ODataQueryOptions (which I don't want, as I don't want to return the sorting data), then it fails.
Is there a way to bypass the initialisation of the default ordering, or have it detect that we already have an OrderBy call in the expression and use that in lieu of seeking a default? My current solution involves creating a new instance of ODataQueryOptions with top/skip removed, applying my custom sort, calling GetQueryAsync, then applying top/skip myself, but it's an ugly hack.
The text was updated successfully, but these errors were encountered:
I think there was a PR to do exactly that i.e. if there's a Skip but no OrderBy then add one. Adding a setting to ODataSattings something like SkipDefaultOrderBy should work.
Version: 5.0.0 (EFCore)
Expected behavior
Results are sorted using the .OrderBy expression.
Actual behavior
A default sort order is applied.
Steps to reproduce
Make an .OrderBy call before .GetQueryAsync, with $top and/or $skip specified. e.g.:
Details
I have an ordering requirement that I can't feasibly represent using OData, so my intent is to order the IQueryable before calling GetQueryAsync.
This works if I don't use OData $skip or $top, but if either of those are specified then the custom ordering is overridden by the GetQueryableMethod > GetDefaultOrderByCall call.
I've tried doing the .OrderBy call after .GetQueryAsync, however if the expression used for my custom order includes navigation properties/children that aren't selected/expanded in the ODataQueryOptions (which I don't want, as I don't want to return the sorting data), then it fails.
Is there a way to bypass the initialisation of the default ordering, or have it detect that we already have an OrderBy call in the expression and use that in lieu of seeking a default? My current solution involves creating a new instance of ODataQueryOptions with top/skip removed, applying my custom sort, calling GetQueryAsync, then applying top/skip myself, but it's an ugly hack.
The text was updated successfully, but these errors were encountered: