简体   繁体   English

如何从带有实体框架的列表中获取以下项目?

[英]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.

相关问题 如何使用实体框架将项目添加到列表属性 - How do i add items to a list property using Entity Framework 从一种到多种情况,我如何获得实体框架中的常见项目 - From a one to many situation how do I get common items in Entity Framework 如何在Entity Framework中将一个上下文中的项目从另一个上下文中删除? - How can I delete items in one context from another in Entity Framework? 如何从实体框架实体(对象)创建列表? - How can I create a List off of an Entity Framework entity (object)? 如何在Entity Framework中使用介于两者之间的类从另一个实体获取数据 - How can I get data from another entity using class in between in Entity Framework 如何从属性设置器访问实体框架实体的上下文? - How can I get to the context of an Entity Framework entity from a property setter? 如何在实体框架中获得带有子实体的实体? - How can i get a entity with sub entities in Entity framework? 我如何链接两个类,使用Entity Framework和LINQ选择并仍然获得列表输出? - How can I link two classes, select and still get a list output using Entity Framework and LINQ? 我可以在实体框架中从表转换为列表吗 - Can i convert from table to list in Entity Framework 如何获取CollectionBase项目列表? - How can I get a list of CollectionBase items?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM