linq,skip(),take实现分页
Posted Fred1987
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linq,skip(),take实现分页相关的知识,希望对你有一定的参考价值。
using (AdventureWorks2012Entities db = new AdventureWorks2012Entities())
{
int num = (from stu in db.Customer orderby stu.CustomerID select stu).ToList().Count;
for (int i = 0; i < num;i=i+100)
{
var students = (from stu in db.Customer
orderby stu.CustomerID
select stu).Skip(i).Take(100).ToList();
foreach (var stu in students)
{
System.Diagnostics.Debug.WriteLine(stu.CustomerID + "," + stu.AccountNumber);
}
int pageCount = i / 100 + 1;
System.Diagnostics.Debug.WriteLine("This is page " + pageCount + "\\n");
}
Console.ReadLine();
}
以上是关于linq,skip(),take实现分页的主要内容,如果未能解决你的问题,请参考以下文章