Can someone suggest a way to create batches of a certain size in linq?
Ideally I want to be able to perform operations in chunks of some configurable amount.
I know everybody used complex systems to do this work, and I really don't get it why.
Take and skip will allow all those operations using the common select with Func
transform function.
Like:
public IEnumerable> Buffer(IEnumerable source, int size)=>
source.Select((item, index) => source.Skip(size * index).Take(size)).TakeWhile(bucket => bucket.Any());