コード例 #1
0
 public void Dispose()
 {
     try
     {
         _table?.DeleteIfExistsAsync()?.Wait();
     }
     catch (Exception e)
     {
         Trace.TraceError(e.ToString());
     }
 }
コード例 #2
0
        public async Task <bool> DropCloudTable(string tableName)
        {
            CloudTable cloudTable = GetCloudTable(tableName);

            return(await cloudTable.DeleteIfExistsAsync());
        }
コード例 #3
0
 /// <summary>
 /// Delete table async.
 /// </summary>
 /// <returns>The async task.</returns>
 public async Task <bool> DeleteTableAsync()
 {
     return(await _cloudTable.DeleteIfExistsAsync());
 }
コード例 #4
0
 public async Task DropTableAsync(string tablename)
 {
     CloudTableClient tableClient = _storageProvider.StorageAccount.CreateCloudTableClient();
     CloudTable       table       = tableClient.GetTableReference(tablename);
     await table.DeleteIfExistsAsync();
 }
コード例 #5
0
 /// <summary>
 /// Delete a table
 /// </summary>
 /// <param name="table">Sample table name</param>
 private static async Task DeleteTableAsync(CloudTable table)
 {
     await table.DeleteIfExistsAsync();
 }
コード例 #6
0
 public static bool DeleteIfExists(this CloudTable table)
 {
     return(table.DeleteIfExistsAsync().ExecuteSynchronously());
 }
コード例 #7
0
        public async Task DeleteTable(string tableName)
        {
            CloudTable table = GetTable(tableName);

            await table.DeleteIfExistsAsync();
        }
コード例 #8
0
ファイル: TableAccess.cs プロジェクト: parvezah/PickSanta
 public void Dispose()
 {
     _ = table.DeleteIfExistsAsync().Result;
 }
コード例 #9
0
 private void deleteTables_ClickAsync(object sender, EventArgs e, CloudTable table)
 {
     table.DeleteIfExistsAsync();
     MessageBox.Show("All the stored data are deleted! \n" + "Table " + table + " is deleted!");
 }
コード例 #10
0
ファイル: FixtureBase.cs プロジェクト: firegiant/Identity
        public void Dispose()
        {
            this.Scope.Dispose();

            _table.DeleteIfExistsAsync();
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: shirhatti/testproj
 public void Main(string[] args)
 {
     _urltable.DeleteIfExistsAsync().Wait();
     _indextable.DeleteIfExistsAsync().Wait();
     Console.ReadLine();
 }
コード例 #12
0
 public async void Clear()
 {
     await _table.DeleteIfExistsAsync();
 }
コード例 #13
0
 /// <summary>
 /// Deletes the given table if exists
 /// </summary>
 /// <returns></returns>
 public async Task DeleteTableAsync(string tableName)
 {
     // Delete the table
     table = tableClient.GetTableReference(tableName);
     await table.DeleteIfExistsAsync();
 }
コード例 #14
0
        public static async Task <String> updateUser(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "update-User/{act}/{name}")] HttpRequestMessage request,
            [Table("Users")] CloudTable cloudTable,
            string name,
            string act,
            ILogger log)
        {
            Console.Out.WriteLine("in updateUser");
            //addition
            CloudTable       table  = null;
            CloudTableClient client = null;

            try
            {
                StorageCredentials  creds   = new StorageCredentials(Environment.GetEnvironmentVariable("accountName"), Environment.GetEnvironmentVariable("accountKey"));
                CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);

                client = account.CreateCloudTableClient();
                table  = client.GetTableReference("Table00" + name);

                Console.WriteLine(table.Uri.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            if (act.Equals("remove"))
            {
                Console.Out.WriteLine("in remove");
                //delete table
                await table.DeleteIfExistsAsync();

                //delete user from Users
                TableOperation retrieve   = TableOperation.Retrieve <TableEntity>(name, "");
                CloudTable     usersTable = client.GetTableReference("Users");
                await usersTable.CreateIfNotExistsAsync();

                TableResult result = await usersTable.ExecuteAsync(retrieve);

                var deleteEntity = (TableEntity)result.Result;

                TableOperation delete = TableOperation.Delete(deleteEntity);

                await usersTable.ExecuteAsync(delete);

                //delete requests
                CloudTable           requestTable = client.GetTableReference("Requests");
                TableQuery <Request> idQuery      = new TableQuery <Request>()
                                                    .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, name));
                TableQuerySegment <Request> queryResult = await requestTable.ExecuteQuerySegmentedAsync(idQuery, null);

                var batchOperation = new TableBatchOperation();
                foreach (var e in queryResult.Results)
                {
                    batchOperation.Delete((TableEntity)e);
                }
                if ((queryResult.Results).Count != 0)
                {
                    await requestTable.ExecuteBatchAsync(batchOperation);
                }

                return(act + " " + name);
            }
            else if (act == "add")
            {
                Console.Out.WriteLine("in add");
                await table.CreateIfNotExistsAsync();

                CloudTable usersTable = client.GetTableReference("Users");
                await usersTable.CreateIfNotExistsAsync();

                User newUser = new User();
                newUser.PartitionKey = name;
                newUser.RowKey       = "";
                newUser.Password     = name;
                newUser.UserType     = "user";

                TableOperation add = TableOperation.InsertOrReplace(newUser);
                await usersTable.ExecuteAsync(add);

                return(act + " " + name);
            }
            return(act + " " + name + " error in action");
        }
コード例 #15
0
ファイル: AzureRepository.cs プロジェクト: wcscmp/PowderBot
 public async Task DropTable()
 {
     await _table.DeleteIfExistsAsync();
 }
コード例 #16
0
        public async Task RunSamples()
        {
            Console.WriteLine("Azure Table Storage - Basic Samples\n");
            Console.WriteLine("Based on https://docs.microsoft.com/en-us/azure/cosmos-db/tutorial-develop-table-dotnet?toc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Ftables%2Ftoc.json&bc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fbread%2Ftoc.json");
            Console.WriteLine("And converted to (cheaper) table storage.");
            Console.WriteLine();



            try
            {
                //string tableName = "demo" + Guid.NewGuid().ToString().Substring(0, 5);
                string tableName = "CustomerEntityDemoTable";

                // Create or reference an existing table
                CloudTable table = await _storageUtils.CreateOrGetTableAsync(connectionString, tableName);

                // Demonstrate basic CRUD functionality
                // 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 _storageUtils.InsertOrMergeEntityAsync(table, customer);

                Console.WriteLine($"Email:{customer.Email}, Phone: {customer.PhoneNumber}");

                // 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 _storageUtils.InsertOrMergeEntityAsync(table, customer);

                Console.WriteLine();

                // Demonstrate how to Read the updated entity using a point query
                Console.WriteLine("Reading the updated Entity.");
                customer = await _storageUtils.RetrieveEntityUsingPointQueryAsync <CustomerEntity>(table, "Harp", "Walter");

                Console.WriteLine($"Email:{customer.Email}, Phone: {customer.PhoneNumber}");
                Console.WriteLine();

                // Select All CustomerEntities in the table
                Console.WriteLine("Selecting All Customer Entities.");
                var customers = await _storageUtils.SelectAll <CustomerEntity>(table);

                Console.WriteLine();

                // Demonstrate how to Delete an entity
                Console.WriteLine("Delete the entity. ");
                await _storageUtils.DeleteEntityAsync(table, customer);

                Console.WriteLine();

                // Delete the table
                await table.DeleteIfExistsAsync();
            }
            catch (Exception ex)
            {
                // If "target machine actively refused it (running locally vs local emulator)"
                // run Microsoft Azure Storage Emulator


                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
            finally
            {
            }
        }
コード例 #17
0
 public static async Task DropTable(CloudTable table)
 {
     await table.DeleteIfExistsAsync();
 }