当前位置: 首页>>代码示例>>C#>>正文


C# CloudTable.CreateIfNotExistsAsync方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExistsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudTable.CreateIfNotExistsAsync方法的具体用法?C# CloudTable.CreateIfNotExistsAsync怎么用?C# CloudTable.CreateIfNotExistsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.Storage.Table.CloudTable的用法示例。


在下文中一共展示了CloudTable.CreateIfNotExistsAsync方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpenAsync

        public Task OpenAsync(PartitionContext context)
        {
            /*client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-ZUMO-APPLICATION", APP_KEY_MOBILE_SERVICES);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            return Task.FromResult<object>(null);*/

            var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
            var tableClient = storageAccount.CreateCloudTableClient();
            sensorLogTable = tableClient.GetTableReference("SensorLog");
            //sensorLogTable = tableClient.GetTableReference("SensorLog" + context.Lease.PartitionId);

            // 閾値の取得
            if (thresholdTempWarning == null)
            {
                var sensorConfigTable = tableClient.GetTableReference("SensorConfig");
                var query = new TableQuery<SensorConfig>();
                var configData = sensorConfigTable.ExecuteQuery(query);
                foreach (SensorConfig config in configData)
                {
                    if (config.PartitionKey == "TemperatureWarning")
                    {
                        thresholdTempWarning = config.Threshold;
                        System.Console.WriteLine("ThresholdTempWarning: " + thresholdTempWarning);
                    }
                    else if (config.PartitionKey == "TemperatureDanger")
                    {
                        thresholdTempDanger = config.Threshold;
                        System.Console.WriteLine("ThresholdTempDanger: " + thresholdTempDanger);
                    }
                }
            }

            return sensorLogTable.CreateIfNotExistsAsync();
        }
开发者ID:kenjihiranabe,项目名称:IoT-Hackathon-Zubogani-2015,代码行数:35,代码来源:SensorEventProcessor.cs

示例2: EnsureTableExists

 private async Task EnsureTableExists(CloudTable table)
 {
     if (!this.created)
     {
         await table.CreateIfNotExistsAsync();
         this.created = true;
     }
 }
开发者ID:jamesholcomb,项目名称:NDomain,代码行数:8,代码来源:AzureEventStore.cs

示例3: MyTestInitialize

        public void MyTestInitialize()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            currentTable = tableClient.GetTableReference(GenerateRandomTableName());
            currentTable.CreateIfNotExistsAsync().AsTask().Wait();

            if (TestBase.TableBufferManager != null)
            {
                TestBase.TableBufferManager.OutstandingBufferCount = 0;
            }
        }
开发者ID:BurtHarris,项目名称:azure-storage-net,代码行数:11,代码来源:TableOperationUnitTests.cs

示例4: AzureStorageRepository

        public AzureStorageRepository(string account, string key, string tableName, bool nagling = true)
        {
            _storageAccount = GetStorageAccount(account, key);

            _tableClient = _storageAccount.CreateCloudTableClient();

            _table = _tableClient.GetTableReference(tableName);

            _table.CreateIfNotExistsAsync();

            EnableNagling(nagling);
        }
开发者ID:WorldWayno,项目名称:AzureStorageTests,代码行数:12,代码来源:AzureStorageRepository.cs

示例5: Configure

        public void Configure()
        {
            // Create the table client.
            _tableClient = _storageAccount.CreateCloudTableClient();
            _urltable = _tableClient.GetTableReference("url");
            _indextable = _tableClient.GetTableReference("index");

            // Create the table if it doesn't exist
            _urltable.CreateIfNotExistsAsync().Wait();
            _indextable.CreateIfNotExistsAsync().Wait();

            // Create index if it doesn't exist
            createIndexIfNotExist().Wait();
        }
开发者ID:shirhatti,项目名称:testproj,代码行数:14,代码来源:AzureTableContext.cs

示例6: MyClassInitialize

        public static async Task MyClassInitialize(TestContext testContext)
        {
            tableClient = GenerateCloudTableClient();
            currentTable = tableClient.GetTableReference(GenerateRandomTableName());
            await currentTable.CreateIfNotExistsAsync();

            for (int i = 0; i < 15; i++)
            {
                TableBatchOperation batch = new TableBatchOperation();

                for (int j = 0; j < 100; j++)
                {
                    DynamicTableEntity ent = GenerateRandomEntity("tables_batch_" + i.ToString());
                    ent.RowKey = string.Format("{0:0000}", j);
                    batch.Insert(ent);
                }

                await currentTable.ExecuteBatchAsync(batch);
            }
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:20,代码来源:TableQueryTaskTests.cs

示例7: Program

        public Program()
        {
            var builder = new ConfigurationBuilder("D:\\testproj\\src\\testproj");
            builder.AddUserSecrets();
            Configuration = builder.Build();

            _version = Configuration["Authentication:AzureStorageAccount:version"];
            // Retrieve the storage account from the connection string.
            _storageAccount = CloudStorageAccount.Parse(Configuration["Authentication:AzureStorageAccount:StorageConnectionString"]);
            // Create the table client.
            _tableClient = _storageAccount.CreateCloudTableClient();

            // Create the table if it doesn't exist.
            _urltable = _tableClient.GetTableReference("url");
            _urltable.CreateIfNotExistsAsync();


            // Create the table if it doesn't exist.
            _indextable = _tableClient.GetTableReference("index");
            _indextable.CreateIfNotExistsAsync();
        }
开发者ID:shirhatti,项目名称:testproj,代码行数:21,代码来源:Program.cs

示例8: MyTestInitialize

 public async Task MyTestInitialize()
 {
     tableClient = GenerateCloudTableClient();
     currentTable = tableClient.GetTableReference(GenerateRandomTableName());
     await currentTable.CreateIfNotExistsAsync();
 }
开发者ID:vinaysh-msft,项目名称:azure-storage-net,代码行数:6,代码来源:TableBatchOperationTaskTest.cs

示例9: MyTestInitialize

 public void MyTestInitialize()
 {
     CloudTableClient tableClient = GenerateCloudTableClient();
     currentTable = tableClient.GetTableReference(GenerateRandomTableName());
     currentTable.CreateIfNotExistsAsync().AsTask().Wait();
 }
开发者ID:Juliako,项目名称:azure-sdk-for-net,代码行数:6,代码来源:TableOperationUnitTests.cs

示例10: MyClassInitialize

        public static async Task MyClassInitialize(TestContext testContext)
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            currentTable = tableClient.GetTableReference(GenerateRandomTableName());
            await currentTable.CreateIfNotExistsAsync();

            // Bulk Query Entities
            for (int i = 0; i < 15; i++)
            {
                TableBatchOperation batch = new TableBatchOperation();

                for (int j = 0; j < 100; j++)
                {
                    var ent = GenerateRandomEnitity("tables_batch_" + i.ToString());
                    ent.RowKey = string.Format("{0:0000}", j);
                    batch.Insert(ent);
                }

                await currentTable.ExecuteBatchAsync(batch);
            }


            complexEntityTable = tableClient.GetTableReference(GenerateRandomTableName());
            await complexEntityTable.CreateAsync();

            // Setup
            TableBatchOperation complexBatch = new TableBatchOperation();
            string pk = Guid.NewGuid().ToString();

            for (int m = 0; m < 100; m++)
            {
                ComplexEntity complexEntity = new ComplexEntity(pk, string.Format("{0:0000}", m));
                complexEntity.String = string.Format("{0:0000}", m);
                complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m };
                complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m };
                complexEntity.Bool = m % 2 == 0 ? true : false;
                complexEntity.BoolPrimitive = m % 2 == 0 ? true : false;
                complexEntity.Double = m + ((double)m / 100);
                complexEntity.DoublePrimitive = m + ((double)m / 100);
                complexEntity.Int32 = m;
                complexEntity.Int32N = m;
                complexEntity.IntegerPrimitive = m;
                complexEntity.IntegerPrimitiveN = m;
                complexEntity.Int64 = (long)int.MaxValue + m;
                complexEntity.LongPrimitive = (long)int.MaxValue + m;
                complexEntity.LongPrimitiveN = (long)int.MaxValue + m;
                complexEntity.Guid = Guid.NewGuid();

                complexBatch.Insert(complexEntity);

                if (m == 50)
                {
                    middleRef = complexEntity;
                }

                // Add delay to make times unique
                Thread.Sleep(100);
            }

            await complexEntityTable.ExecuteBatchAsync(complexBatch);
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:61,代码来源:TableQueryableTests.cs


注:本文中的Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExistsAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。