private static async Task BasicDataOperationsAsync(CloudTable table) { // Create an instance of a customer entity. See the Model\CustomerEntity.cs for a description of the entity. CustomerEntity customer = new CustomerEntity("Harp", "Walter") { email = "*****@*****.**", phoneNumber = "425-555-0101" }; // Demonstrate how to insert the entity Console.WriteLine("Insert an Entity."); customer = await SampleUtils.InsertOfMergeEntityAsync(table, customer); // Demonstrate how to Update the entity by changing the phone number Console.WriteLine("Update an existing Entity using the InsertOrMerge Upsert Operation."); customer.phoneNumber = "425-555-0105"; await SampleUtils.InsertOfMergeEntityAsync(table, customer); Console.WriteLine(); // Demonstrate how to Read the updated entity using a point query Console.WriteLine("Reading the updated Entity."); customer = await SampleUtils.RetrieveEntityUsingPointQueryAsync(table, "Harp", "Walter"); Console.WriteLine(); // Demonstrate how to Delete an entity //Console.WriteLine("Delete the entity. "); //await SampleUtils.DeleteEntityAsync(table, customer); //Console.WriteLine(); }
private static async Task BasicDataOperationsAsync(CloudTable table) { Console.WriteLine("Type I for insert or U for update or X for exit and press enter"); string option = Console.ReadLine(); Console.WriteLine("Enter last name:"); string lName = Console.ReadLine(); Console.WriteLine("Enter first name:"); string fName = Console.ReadLine(); Console.WriteLine("Enter email:"); string email = Console.ReadLine(); Console.WriteLine("Enter phone:"); string phone = Console.ReadLine(); CustomerEntity customer = new CustomerEntity(lName, fName) { Email = email, PhoneNumber = phone }; if (option == "I") { Console.WriteLine("Insert an Entity."); await SampleUtils.InsertOrMergeEntityAsync(table, customer); } else if (option == "U") { Console.WriteLine("Update an existing Entity using the InsertOrMerge Upsert Operation."); //customer.PhoneNumber = phone; await SampleUtils.InsertOrMergeEntityAsync(table, customer); Console.WriteLine(); } else { return; } // Demonstrate how to Read the updated entity using a point query Console.WriteLine("Reading the Entity."); customer = await SampleUtils.RetrieveEntityUsingPointQueryasync(table, lName, fName); Console.WriteLine(customer.PartitionKey + " " + customer.RowKey + " " + customer.Email + " " + customer.PhoneNumber); // Demonstrate how to Delete an entity //Console.WriteLine("Delete the entity. "); //await SamplesUtils.DeleteEntityAsync(table, customer); //Console.WriteLine(); }