コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        private async Task DeleteEntityAsync(CloudTable table, PersonEntity deleteEntity)
        {
            if (deleteEntity == null)
            {
                throw new ArgumentNullException("deleteEntity");
            }

            TableOperation deleteOperation = TableOperation.Delete(deleteEntity);
            await table.ExecuteAsync(deleteOperation);
        }