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 - )).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分页扩展(转)的更多相关文章
- linq分页扩展
直接上代码了 public static List<T> ToPagedList<T>(this IEnumerable<T> allItems, int page ...
- yii2分页扩展之实现跳转到具体某页
作者:白狼 出处:http://www.manks.top/yii2_linkpager_widget.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文 ...
- Linq 分页不可缺少的两个方法
//LINQ分页的方法 //1.获取总页数 public int GetPageCount(int pageSize)//pageSize是每页的行数 { //先查出总共有多少行 int rowCou ...
- C# SQL优化 及 Linq 分页
每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...
- Linq分页查询
//Linq分页查询 int pageIndex = Convert.ToInt32(HttpContext.Current.Request["PageIndex"]); int ...
- Linq分页
/// <summary> /// Linq分页 /// </summary> ;//每页条数 ;//总条数 ;//当前第几页 public static string con ...
- LINQ分页和排序,skip和Take 用法
LINQ分页和排序,skip和Take 用法 dbconn.BidRecord.OrderBy(p=>p.bid_id).ToList<BidRecord>().OrderBy(p ...
- ReactiveX 学习笔记(11)对 LINQ 的扩展
Interactive Extensions(Ix) 本文的主题为对 Ix 库,对 LINQ 的扩展. Buffer Ix.NET Buffer Ix.NET BufferTest Buffer 方法 ...
- LINQ 分页 和存储过程分页
存储过程分页 SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY CreateDate DESC) AS RowNo, EstateAddress, E ...
随机推荐
- FreeSWITCH 1.6关于视频通话的一些测试
简单的测试了一下,暂时没把精力放到这一块. ① 视频编码透传的设置(使用代理模式). 修改internal.xml文件的以下参数: <param name="inbound-proxy ...
- 粒子群算法 Particle Swarm Optimization, PSO(转贴收藏)
粒子群算法(1)----粒子群算法简介 http://blog.csdn.net/niuyongjie/article/details/1569671 粒子群算法(2)----标准的粒子群算法 htt ...
- git commit时message的问题
1: 在执行git commit的时候,有两种办法为该commit添加message信息一种是git commit -m 'your message'另一种是git commit会打开commit-e ...
- [Lonlife1031]Bob and Alice are eating food(递推,矩阵快速幂)
题目链接:http://www.ifrog.cc/acm/problem/1031 题意:6个水果中挑出n个,使得其中2个水果个数必须是偶数,问有多少种选择方法. 设中0代表偶数,1代表奇数.分别代表 ...
- CUBRID学习笔记 1 简介 cubrid教程
CUBRID 是一个全面开源,且完全免费的关系数据库管理系统.CUBRID为高效执行Web应用进行了高度优化,特别是需要处理大数据量和高并发请求的复杂商务服务.通过提供独特的最优化特性,CUBRID可 ...
- Domion OA 日记
我现在使用的是IBM的 Lotus Dimion 8.5 以下内容是个人的浅显了解,在此记录下,已作为后续记录的翻看 第一次接触文档型数据库,确实颠覆了我对数据模型的认知,我之前一直用sql的 文档型 ...
- elcipse 中利用maven创建web工程
如何创建: http://huxiaoheihei.iteye.com/blog/1766986 遇到的问题: 1: 如果spring MVC配置了 <servlet> <servl ...
- jsp get方式请求参数中包含中文乱码问题解决
1. 自己接收到参数之后在后台进行转码处理 2: 修改tomcat的配置文件 server.xml <Connector port="8080" protocol=&quo ...
- Redis基础知识之—— hset 和hsetnx 的区别
命令参数:HSET key field valueHSETNX key field value 作用区别:HSET 将哈希表 key 中的域 field 的值设为 value .如果 key 不存在, ...
- C++中的虚函数与纯虚函数
这个吧,我也不怎么知道,所以,大家来看这两篇文章哦: http://blog.csdn.net/hackbuteer1/article/details/7558868 http://blog.csdn ...