原文地址:http://www.cnblogs.com/RainbowInTheSky/p/4590508.html

     public static List<T> ToPagedList<T>(this IEnumerable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, int>> keySelector)
        {
            var itemList = allItems.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }
        public static List<T> ToPagedList<T>(this IEnumerable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, bool>> keySelector)
        {
            var itemList = allItems.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }
        public static List<T> ToPagedList<T>(this IEnumerable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, string>> keySelector)
        {
            var itemList = allItems.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }
        public static List<T> ToPagedList<T>(this IEnumerable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, DateTime>> keySelector)
        {
            var itemList = allItems.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }
        public static List<T> ToPagedList<T>(this IQueryable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, int>> keySelector)
        {
            var itemList = allItems.OrderBy(keySelector).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }
        public static List<T> ToPagedList<T>(this IQueryable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, bool>> keySelector)
        {
            var itemList = allItems.OrderBy(keySelector).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }
        public static List<T> ToPagedList<T>(this IQueryable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, string>> keySelector)
        {
            var itemList = allItems.OrderBy(keySelector).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }
        public static List<T> ToPagedList<T>(this IQueryable<T> allItems, int pageIndex, int pageSize, Expression<Func<T, DateTime>> keySelector)
        {
            var itemList = allItems.OrderBy(keySelector).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
            return itemList;
        }

 

相关文章:

  • 2022-12-23
  • 2021-08-03
  • 2022-01-30
  • 2021-06-06
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案