public async Task BasicTableOperationsAsync(CloudTable table) { PersonEntity customer = new PersonEntity("Harp", "Walter") { Email = "*****@*****.**", PhoneNumber = "425-555-0101" }; Console.WriteLine("2. Update an existing Entity using the InsertOrMerge Upsert Operation."); customer.PhoneNumber = "425-555-0105"; customer = await InsertOrMergeEntityAsync(table, customer); Console.WriteLine("3. Reading the updated Entity."); customer = await RetrieveEntityUsingPointQueryAsync(table, "Harp", "Walter"); Console.WriteLine("4. Delete the entity. "); await DeleteEntityAsync(table, customer); }
private async Task<PersonEntity> InsertOrMergeEntityAsync(CloudTable table, PersonEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity); TableResult result = await table.ExecuteAsync(insertOrMergeOperation); PersonEntity insertedCustomer = result.Result as PersonEntity; return insertedCustomer; }
private async Task DeleteEntityAsync(CloudTable table, PersonEntity deleteEntity) { if (deleteEntity == null) { throw new ArgumentNullException("deleteEntity"); } TableOperation deleteOperation = TableOperation.Delete(deleteEntity); await table.ExecuteAsync(deleteOperation); }