Even after setting EnsureStableOrdering = false
in the ODataQuerySettings
ODataQueryOptions
is still applying default sorting in the collection of navigation entities when expand is specified in the user query, but EnsureStableOrdering = false
is working as excepted on primary entity. Also if PageSize
is removed from the ODataQuerySettings
, sorting is not happening.
public class CustomEnableQuery : EnableQueryAttribute
{
private static int _pageSize;
static CustomEnableQuery()
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
_pageSize = Convert.ToInt32(configuration["pagesize"]);
}
public override IQueryable ApplyQuery(IQueryable queryable,
ODataQueryOptions queryOptions)
{
var result = queryOptions.ApplyTo(queryable, new ODataQuerySettings { PageSize = _pageSize, EnsureStableOrdering = false, IgnoredQueryOptions = AllowedQueryOptions.Skip });
return result;
}
}
What is the correct solution for problem and how to stop default sorting on navigation entities?
Nivash RK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3