[英]How can I get the following items from a list with entity framework?
I have a very large list and I want to extract in parts of 50 items for which I will implement the following: 我的清单很大,我想提取50个项目的一部分,为此我将实现以下内容:
try
{
using (var context = new ccoFinalEntities())
{
return context.sales
.Where(p => true == p.status && myID == p.id)
.Take(50)
.ToList();
}
}
catch
{
return null;
}
I assume this will return me the first 50 items, my question is: 我认为这将返回我的前50个项目,我的问题是:
How can I get the next 50 and so on until extract the list completely? 如何获得下一个50,依此类推,直到完全提取列表?
Any comments or suggestions are welcome 欢迎任何意见或建议
public List<Item> GetDate(int page, int size = 50)
{
try
{
using (var context = new ccoFinalEntities())
{
return context.sales.Where(p => true == p.status && myID == p.id)
.Skip(page * size).Take(size).ToList();
}
}
catch
{
return null;
}
}
Then call: 然后致电:
GetData(0);
GetData(1);
GetData(2);
GetData(3);
..... .....
Skip
ignore first page * size
(1 * 50, 2 * 50, ...) items and Take
size
(50) item Skip
忽略第一page * size
(1 * 50,2 * 50,......)的项目和Take
size
(50)项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.