Beispiel #1
0
 /// <summary>
 /// 分页查询 带输出
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <param name="pageIndex"></param>
 /// <param name="pageSize"></param>
 /// <param name="rowCount"></param>
 /// <param name="whereLambda"></param>
 /// <param name="orderBy"></param>
 /// <param name="isAsc"></param>
 /// <returns></returns>
 public List <TEntity> GetPagedList <TKey>(int pageIndex, int pageSize, ref int rowCount, Expression <Func <TEntity, bool> > whereLambda, Expression <Func <TEntity, TKey> > orderByLambda, bool isAsc = true)
 {
     rowCount = entities.Where(whereLambda).Count();
     if (isAsc)
     {
         return(entities.OrderBy(orderByLambda).Where(whereLambda).Skip((pageIndex - 1) * pageSize).Take(pageSize).AsNoTracking().ToList());
     }
     else
     {
         return(entities.OrderByDescending(orderByLambda).Where(whereLambda).Skip((pageIndex - 1) * pageSize).Take(pageSize).AsNoTracking().ToList());
     }
 }