O'Reilly logo

Guide to NoSQL with Azure Cosmos DB by Daron Yondem, Gaston C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required