Inserting POCOs

Now we will write the generalized InsertCompetition asynchronous method, which receives a Competition instance, inserts it into the document collection, and displays a message indicating that the competition with a specific status and title has been created. 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<Competition> InsertCompetition(Competition competition) { var documentResponse = await client.CreateDocumentAsync(collectionUri, competition); if (documentResponse.StatusCode == System.Net.HttpStatusCode.Created) { Console.WriteLine($"The {competition.Status} ...

Get Guide to NoSQL with Azure Cosmos DB now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.