Is there a way to add a Default Sort field, so that I can UsePaging and UserSorting, but if no order is specified I add a field, such as Id. But if the user does specify an order, then don't add the default.
For example, I can add the default sort to the query method, but then no other sorting works
[UseContext]
[UsePaging]
[UseProjection]
[UseFiltering]
[UseSorting]
public IQueryable<Property> GetProperties([ScopedService] PropContext dbContext)
{
return dbContext.Properties
.OrderBy(p => p.Id); // Default sort by Prop Id
}
If don't have a sort, then Entity Framework shows a warning:
The query uses a row limiting operator ('Skip'/'Take') without an 'OrderBy' operator.
This may lead to unpredictable results
And I've seen some unexpected results