简体   繁体   English

AzureStorage库v2中的“tableClient.CreateTableIfNotExist”在哪里?

[英]Where is the “tableClient.CreateTableIfNotExist” in AzureStorage library v2?

In Windows Azure Storage, we used to do this to create a table : 在Windows Azure存储中,我们曾经这样做来创建表:

var tableClient = account.CreateCloudTableClient();
tableClient.CreateTableIfNotExist(TableName);

I just downloaded the last version of the azure storage library (v2), and my previous code doesn't work anymore : 我刚刚下载了最新版本的azure存储库(v2),而我之前的代码不再适用了:

'Microsoft.WindowsAzure.Storage.Table.CloudTableClient' does not contain a definition for 'CreateTableIfNotExist' and no extension method 'CreateTableIfNotExist' accepting a first argument of type 'Microsoft.WindowsAzure.Storage.Table.CloudTableClient' could be found. 'Microsoft.WindowsAzure.Storage.Table.CloudTableClient'不包含'CreateTableIfNotExist'的定义,并且没有扩展方法'CreateTableIfNotExist'可以找到接受类型'Microsoft.WindowsAzure.Storage.Table.CloudTableClient'的第一个参数。

What is the good code in v2 ? v2中的优秀代码是什么?

In v2 there's some breaking changes. 在v2中有一些重大变化。 Here's the new code : 这是新代码:

    var tableClient = account.CreateCloudTableClient();
    // Create the table if it doesn't exist.
    var cloudTable = tableClient.GetTableReference(TableName);
    cloudTable.CreateIfNotExists();

Some good inputs : 一些好的投入:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM