我在Web API项目中遇到了PaginatedList的问题.
在存储库中有一个方法,如:
public virtual PaginatedList<T> Paginate<TKey>(int pageIndex,int pageSize,Expression<Func<T,TKey>> keySelector,bool>> predicate,params Expression<Func<T,object>>[] includeProperties) { IQueryable<T> query = AllIncluding(includeProperties).OrderBy(keySelector); query = (predicate == null) ? query : query.Where(predicate); return query.ToPaginatedList(pageIndex,pageSize); }
但是,当我尝试使用它时,像这样:
var a = repository.Paginate<Region>(pageNo,pageSize,x => x.ID,null);
我收到此错误:
Cannot implicitly convert type ‘int’ to
‘Domain.Entities.Dictionaries.Region’
我究竟做错了什么?