private static async Task UpsertDocumentAsync()
{
Console.WriteLine("\n1.6 - Upserting a document");
var upsertOrder = GetSalesOrderSample("SalesOrder3");
ResourceResponse<Document> response = await client.UpsertDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), upsertOrder);
var upserted = response.Resource;
Console.WriteLine("Request charge of upsert operation: {0}", response.RequestCharge);
Console.WriteLine("StatusCode of this operation: {0}", response.StatusCode);
Console.WriteLine("Id of upserted document: {0}", upserted.Id);
Console.WriteLine("AccountNumber of upserted document: {0}", upserted.GetPropertyValue<string>("AccountNumber"));
upserted.SetPropertyValue("AccountNumber", "updated account number");
response = await client.UpsertDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), upserted);
upserted = response.Resource;
Console.WriteLine("Request charge of upsert operation: {0}", response.RequestCharge);
Console.WriteLine("StatusCode of this operation: {0}", response.StatusCode);
Console.WriteLine("Id of upserted document: {0}", upserted.Id);
Console.WriteLine("AccountNumber of upserted document: {0}", upserted.GetPropertyValue<string>("AccountNumber"));
} |