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;
            }
  • 相关阅读:
    django 之 用户忘记密码的解决办法
    Django 富文本ckeditor 在模板中的实现
    MySQL密码的恢复方法
    sublime 快捷键
    linux 修改用户密码
    ubuntu 下重启 mysql
    python 控制浏览器模块
    读书笔记:从小工到专家(一)
    urlparse 模块
    python 标准内建函数
  • 原文地址:https://www.cnblogs.com/wangjunwei/p/4601458.html
Copyright © 2011-2022 走看看