1
votes
var log = string.IsNullOrEmpty(filter?.search) 
 ? _appLog.Get().OrderByDescending(x => x.Date)
 : _appLog.Get().Where(p => p.ProcessName == filter.Search).OrderByDescending(x => x.Date);

log = Pagination(log.AsQueryable(), filter, "Date", "LogList");

The error is at the Pagination, when log.AsQueryable() try to convert from IOrderedQueryable to IQueryable

Cannot Implicitly convert type IQueryable to IOrderedQueryable

Someone know how i can do this with an alternative way ?

1
Could you post the exact error message? I suspect it included type arguments. It would also be good to show exactly where, rather than just "here". - Jon Skeet

1 Answers

0
votes

I think the problem here is that Pagination() returns IQueryable<T>, but you are assigning the result back to log which is IOrderedQueryable<T> (since both parts of the conditional operation are ordered). Fortunately, it looks like you aren't using the ordered part, so you can presumably just change log om the first time to be explicitly just IQueryable<T> rather than var (which is picking up IOrderedQueryable<T>):

IQueryable<whatever> log = ...

Alternatively, just use a different variable for the result:

var query = ...
var log = Pagination(query, filter, "Date", "LogList");