尝试将orderby语句添加到我的通用存储库方法并获取以下错误.不知道为什么我似乎能够在其他情况下将.OrderBy添加到IQueryable.
我错过了什么?
得到错误:
Cannot implicitly convert type ‘System.Linq.IOrderedEnumerable’ to ‘System.Linq.IQueryable’
public class QuickbooksRespository<TEntity> where TEntity : class,Intuit.Ipp.Data.IEntity,new() { public virtual IQueryable<TEntity> GetAll( int page,int pageSize,Func<TEntity,object> orderbyascending = null,object> orderbydescending = null) { int skip = Math.Max(pageSize * (page - 1),0); IQueryable<TEntity> results = _qbQueryService .Select(all => all); if (orderbyascending != null) { results = results.OrderBy(orderbyascending); } if (orderbydescending != null) { results = results.OrderByDescending(orderbydescending); } return results .Skip(skip) .Take(pageSize); } }