Created
June 23, 2020 11:53
-
-
Save gsscoder/9c6f724a4acd7ee1b4f93f19330df1bd to your computer and use it in GitHub Desktop.
C# extension method to copy all CosmosDB iterator items to a sequence
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
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Microsoft.Azure.Cosmos; | |
public static class FeedIteratorExtensions | |
{ | |
public static async Task<IEnumerable<T>> ReadAllAsync<T>(this FeedIterator<T> iterator) | |
{ | |
var result = new List<T>(); | |
while (iterator.HasMoreResults) { | |
result.AddRange(await iterator.ReadNextAsync()); | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment