从Entitycollection中删除实体

时间:2017-02-06 14:32:35

标签: c# entitycollection

在实体集合中,我有4个实体。现在我需要按范围选择实体,这意味着我需要选择前两个实体。

之后我需要从实体集合中删除前两个实体,然后选择接下来的两个实体。

伪代码

Entitycollection EC = totalValues;//here totalValues having 4 entities.
int startrange = 0;
int uptoRange = 2;
here i need to select the 0 to 2 Index entities from the entity Collection
forloop (<loop the newly selected value >)
{

}

最后我需要删除所选的值。

2 个答案:

答案 0 :(得分:0)

将这些实体集合转换为列表,然后执行

list.RemoveRange(int index,int count);

这将删除该特定范围。

答案 1 :(得分:0)

我们可以使用跳过并采用预定义方法来实现此方案。

**pseudocode** 

int startrange = 0;
int uptoRange = 2;
int totalloop = EC.Entities.count;
for(int i=0;i<= totalloop;i++)
{
foreach(Entity Ent in EC.Entities.skip(startrange).take(uptoRange))
{

}
  startrange += uptoRange 
}
相关问题