DAL数据层
/// <summary>
/// 按条件查询,分页,排序
/// </summary>
public IEnumerable<T> GetPagedList<S>(int pageIndex, int pageSize, out int rowCount, Expression<Func<T, bool>> where, Expression<Func<T, S>> orderBy, bool isAsc, params Expression<Func<T, object>>[] includs)
{
List<T> list;
IQueryable<T> dbQuery = mContext.Set<T>();
foreach (Expression<Func<T, object>> includ in includs)
{
dbQuery = dbQuery.Include(includ);
}
if (where != null)
{
dbQuery = dbQuery.Where(where);
}
rowCount = dbQuery.Count();
if (query.PageSize < 1) query.PageSize = 1;
if (query.PageIndex < 1) query.PageIndex = 1;
if (((query.PageIndex - 1) * query.PageSize) >= rowCount) query.PageIndex = rowCount % query.PageSize > 0 ? rowCount / query.PageSize + 1 : rowCount / query.PageSize;
if (isAsc)
list = dbQuery.AsNoTracking().OrderBy(orderBy).Skip(pageSize * (pageIndex - 1)).Take