1

In a entity collection i have the 4 Entities.Now I need to select the entities by range which means I need to select first two entities.

After that I need to remove the first two entities from the entity collection and choose the next two entities.

pseudocode

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 >)
{

}

Finally I need to remove the selected value.

User
  • 45
  • 1
  • 10
  • How about [`EC.Take(3)`](https://msdn.microsoft.com/en-us/library/bb503062(v=vs.110).aspx)? – DavidG Feb 06 '17 at 14:41

2 Answers2

0

Convert those entities collection to a list and then do

list.RemoveRange(int index,int count);

This removes that specific range.

Teja
  • 305
  • 1
  • 6
0

We can use the skip and take predefined methods to achieve this scenario.

**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 
}
User
  • 45
  • 1
  • 10