zoukankan      html  css  js  c++  java
  • linq分页扩展(转)

    原文地址: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;
            }
  • 相关阅读:
    11组 团队展示
    11组Alpha冲刺4/6
    11组Alpha冲刺2/6
    11组Alpha冲刺3/6
    EF code first 分页显示
    多条件分页存储过程控制器写法
    UML的9种图
    C#设计模式(2)——简单工厂模式
    多条件分页存储过程PageCommon写法
    五分钟读懂UML类图
  • 原文地址:https://www.cnblogs.com/wangjunwei/p/4601458.html
Copyright © 2011-2022 走看看