Calculating a cross-partition aggregate with an asynchronous LINQ query
The following lines declare the code for the DoesCompetitionWithTitleExistWithLinq
asynchronous static method, which builds a LINQ query to count the number of competitions with the received title. In order to compute this aggregate, we must run a cross-partition query, because the title for the competition can be at any location; that is, at any zip code.
Add the following lines to the existing code of the Program.cs
file. The code file for the sample is included in the learning_cosmos_db_05_01
folder in the SampleApp2/SampleApp1/Program.cs
file:
private static async Task<bool> DoesCompetitionWithTitleExistWithLinq(string competitionTitle) { var competitionsCount = await client.CreateDocumentQuery<Competition>(collectionUri, new FeedOptions() { EnableCrossPartitionQuery = true, MaxItemCount = 1, }) .Where(c => c.Title == competitionTitle...