-
-
Save waldyrfelix/1024270 to your computer and use it in GitHub Desktop.
BatchAggregate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<IList<T>> BatchAggregate<T>(this IEnumerable<T> source, int batchSize) | |
{ | |
var enumerator = source.GetEnumerator(); | |
for (int page = 0; enumerator.MoveNext(); 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