Batching with LINQ
items.static IEnumerable<IEnumerable<T>> Batch<T>(IEnumerable<T> source, int batchSize)
{
return source.Select((item, inx) => new { item, inx })
.GroupBy(x => x.inx / maxItems)batchSize)
.Select(g => g.Select(x => x.item));
}
https://stackoverflow.com/questions/13731796/create-batches-in-linq