Skip to content

Instantly share code, notes, and snippets.

@juanplopes
Forked from waldyrfelix/gist:1024270
Created June 14, 2011 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanplopes/1024285 to your computer and use it in GitHub Desktop.
Save juanplopes/1024285 to your computer and use it in GitHub Desktop.
BatchAggregate
public static IEnumerable<IList<T>> BatchAggregate<T>(this IEnumerable<T> source, int batchSize)
{
for (int page = 0; page < source.Count(); page = page + batchSize)
{
var list = source
.Skip(page)
.Take(batchSize)
.ToList();
yield return list;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment