public DemoAdapter(DocumentClient client, string databaseName, string collectionName) { this.client = client ?? throw new ArgumentNullException(nameof(client)); this.databaseName = databaseName ?? throw new ArgumentNullException(nameof(databaseName)); this.collectionName = collectionName ?? throw new ArgumentNullException(nameof(collectionName)); this.monitor = new CosmosDbPerformanceMonitor(); var collectionUri = UriFactory.CreateDocumentCollectionUri(this.databaseName, this.collectionName); var descriptor = new CollectionDescriptor(this.monitor, client, collectionUri); this.Authors = new AuthorEntityClient(descriptor); this.BlogPosts = new BlogPostEntityClient(descriptor); }
internal static async Task <List <T> > ToListAsync <T>(this IDocumentQuery <T> query, CosmosDbPerformanceMonitor monitor, CancellationToken cancellation) { if (query == null) { throw new ArgumentNullException(nameof(query)); } var results = new List <T>(); while (query.HasMoreResults) { var feed = await query.ExecuteNextAsync <T>(cancellation); monitor.Increment(feed.RequestCharge); results.AddRange(feed); } return(results); }