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

    直接上代码了

    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;
            }

  • 相关阅读:
    软件测试中桩模块与驱动模块的概念与区别(转载),打桩
    DataFactory使用和注意,排列组合
    SCWS中文分词,功能函数实例应用
    按指定长度截取中英文混合字符串
    CSS截取中英文混合字符串长度
    使DIV相对窗口大小左右拖动始终水平居中
    浮动5-常用列表显示(案例)
    多选项卡切换原理
    使当前对象相对于上层DIV 水平、垂直居中定位
    使图片相对于上层DIV始终水平、垂直都居中
  • 原文地址:https://www.cnblogs.com/RainbowInTheSky/p/4590508.html
Copyright © 2011-2022 走看看