I return IOrderedQueryable<T>like this:
response.Data = Expressions
.ApplySorts(request, result)
.Skip(request.Skip)
.Take(request.Take)
.ToList();
Here is my class that contains a method for returning IOrderedQueryable<T>.
public static class Expressions
{
public static IOrderedQueryable<T> ApplySorts<T>(
DataRequest request, IQueryable<T> items)
{
var sorts = request.Sort;
if (sorts != null)
{
foreach (var sort in sorts)
{
items = items.OrderBy(sort.Field + " " + sort.Dir);
}
}
return (IOrderedQueryable<T>)items;
}
}
But at runtime, I get this error:
{"The Skip method is supported only for sorted input in LINQ for Entity. The OrderBy method must be called before the Skip method." }
Please note that there are currently no species; however, the return value ApplySorts<T>()should still return the type that expects Skip()no?
source
share