直接上代码了

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 - )).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 - )).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 - )).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 - )).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 - )).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 - )).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 - )).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 - )).Take(pageSize).ToList();
return itemList;
}

linq分页扩展的更多相关文章

  1. linq分页扩展(转)

    原文地址:http://www.cnblogs.com/RainbowInTheSky/p/4590508.html public static List<T> ToPagedList&l ...

  2. yii2分页扩展之实现跳转到具体某页

    作者:白狼 出处:http://www.manks.top/yii2_linkpager_widget.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文 ...

  3. Linq 分页不可缺少的两个方法

    //LINQ分页的方法 //1.获取总页数 public int GetPageCount(int pageSize)//pageSize是每页的行数 { //先查出总共有多少行 int rowCou ...

  4. C# SQL优化 及 Linq 分页

    每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...

  5. Linq分页查询

    //Linq分页查询 int pageIndex = Convert.ToInt32(HttpContext.Current.Request["PageIndex"]); int ...

  6. Linq分页

    /// <summary> /// Linq分页 /// </summary> ;//每页条数 ;//总条数 ;//当前第几页 public static string con ...

  7. LINQ分页和排序,skip和Take 用法

    LINQ分页和排序,skip和Take 用法 dbconn.BidRecord.OrderBy(p=>p.bid_id).ToList<BidRecord>().OrderBy(p ...

  8. ReactiveX 学习笔记(11)对 LINQ 的扩展

    Interactive Extensions(Ix) 本文的主题为对 Ix 库,对 LINQ 的扩展. Buffer Ix.NET Buffer Ix.NET BufferTest Buffer 方法 ...

  9. LINQ 分页 和存储过程分页

    存储过程分页 SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY CreateDate DESC) AS RowNo, EstateAddress, E ...

随机推荐

  1. github与eclipse结合使用

    github是现在流行的代码托管平台,今天以eclipse为例讲解github的使用,新建项目,提交eclipse项目到github,新建分支,合并分支 1.github上新建项目 记下githug项 ...

  2. Oracle的权限管理

    --授予系统权限语法 grant system_privilege | all privileges --可以设置select any dictionary权限之外的索引系统权限 to {user i ...

  3. [转载]C++Assert()函数

    assert宏的原型定义在<assert.h>中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: #include <assert.h> void assert( i ...

  4. Tomcat翻译--Tomcat Web Application Deployment(Tomcat中部署web应用)

    原文:http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html Introduction(介绍) Deployment is the te ...

  5. SpringBoot_异常_01_Caused by: java.lang.BootstrapMethodError: java.lang.NoSuchMethodError

    一.异常信息 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gsonB ...

  6. MySQL--Basic(一)

    停止与启动服务命令: net stop mysql net start mysql 修改MySQL提示符: mysql>prompt \u@\h \d> MySQL语句规范: 关键字与函数 ...

  7. BEC listen and translation exercise 39

    What about jigsaw puzzle design for visually handicapped?给视觉障碍人士设计拼图怎么样? Length is 50cm, and then th ...

  8. NO3:步履蹒跚-完成第一章节学习

    第一章小记: 每个C程序都要求有一个main()函数(多于一个main()函数是不合法的(已犯错:在VS 2010一个项目里两个C文件都有main函数,不能编译通过,必须删除一个文件,永记)).mai ...

  9. 【LeetCode】081. Search in Rotated Sorted Array II

    题目: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would t ...

  10. Cg与RenderMonkey 之旅

    http://news.mydrivers.com/1/15/15020_all.htm [前言] 您可能还没有意识到---您手头的这块显卡(或者说这块GPU)---它不仅仅是一个应用工具(游戏.平面 ...