Home

Foreach capping at 1000 iterations

I frustratingly can't figure out what's causing this limitation. When running a foreach loop I noticed the result set was smaller than I was expecting, I threw an index in there to debug when I noticed it seems to be capping at 1000 iterations. Any idea why that would be and how I can go about fixing it?

I am connecting to an OData 3 source via WCF 5.5

Persons.Count().Dump();
//Result: 1451

int i=0;
foreach(var person in Persons){
    i++;
}
Console.WriteLine("i: "+i);
Result: i: 1000

Comments

  • Ok, it seems like its a limitation of the OData connection. I was able to get around it by skipping the first thousand records and concatenating the remainder.
    Persons.ToList().Concat(Persons.Skip(1000).ToList());
    This feels a bit hacky though, I have to imagine there must be a better way.

Sign In or Register to comment.