/// <summary>
 /// 获取分页后的数据
 /// </summary>
 /// <typeparam name="T">实体类型</typeparam>
 /// <param name="source">数据源IQueryable</param>
 /// <param name="pagination">分页参数</param>
 /// <param name="thenOrderBy">再排序</param>
 /// <returns></returns>
 public static IQueryable <T> GetPagination <T>(this IQueryable <T> source, Pagination pagination, params (string SortField, string SortType)[] thenOrderBy)
Exemple #2
0
 /// <summary>
 /// 获取分页后的数据
 /// </summary>
 /// <typeparam name="T">实体类型</typeparam>
 /// <param name="source">数据源IQueryable</param>
 /// <param name="pagination">分页参数</param>
 /// <returns></returns>
 public static IQueryable <T> GetPagination <T>(this IQueryable <T> source, Pagination pagination)
 {
     pagination.records = source.Count();
     source             = source.OrderBy($"{pagination.sidx} {pagination.sord}");
     return(source.Skip((pagination.page - 1) * pagination.rows).Take(pagination.rows));
 }
 /// <summary>
 /// 获取分页后的数据
 /// </summary>
 /// <typeparam name="T">实体类型</typeparam>
 /// <param name="source">数据源IQueryable</param>
 /// <param name="pagination">分页参数</param>
 /// <returns></returns>
 public static IQueryable <T> GetPagination <T>(this IQueryable <T> source, Pagination pagination)
 {
     pagination.records = source.Count();
     return(source.OrderBy(pagination.SortField, pagination.SortType).Skip((pagination.page - 1) * pagination.rows).Take(pagination.rows));
 }