I have a dictionary of jobs which need writing to XML for site map usage.
I cannot have the files going over 50,000 records and so need a way of paging this information or something along these lines.
This method decides if the total number of jobs is greater than 30,000.
How could I change my else to include paging?
Add Skip
before Take
in your (inner) for loop.
int newJobCount = JobCount / 4;
for (int i = 0; i < 4; i++)
{
Test(item.Value.BrandName, item.Value.CountryCode, item.Value.Jobs.Values.Skip(newJobCount * i).Take(newJobCount).ToList());
}
Side note regarding newJobCount
If you want to limit number of jobs per page to 3000, then following will be better:
int pageCount = JobCount/3000 + (JobCount % 3000 == 0 ? 0 : 1);
for (int i = 0; i < pageCount; i++)
{
Test(item.Value.BrandName, item.Value.CountryCode, item.Value.Jobs.Values.Skip(3000 * i).Take(3000).ToList());
}