如何获取在我的 Azure 存储帐户中创建的所有现有表?
你以前是这样的
CloudTableClient tableClient;
IEnumerable<CloudTable> AllTables = tableClient.ListTables();
但是,我似乎无法在 CloudTableClient
实例上调用 ListTables
方法。我正在使用 Microsoft.WindowsAzure.Storage 版本 9.3.0
;
EDIT
这是针对.NET CORE的
最佳答案
Go straight to the
EDIT
paragraph below if you looking for the .NET core answer
嗯,看来您没有创建 tableClient
的实例
CloudTableClient tableClient = new CloudTableClient("YOUR CONNECTION STRING");
var AllTables = tableClient.ListTables();
if(AllTables != null)
{
foreach (var table in AllTables)
{
// table.Name is your property
}
}
该方法在微软文档上
EDIT
除此之外,OP 刚刚表示他们正在使用 .NET CORE
.NET Core 尚未包含 API 的同步实现
ListTables 没有方法,因此您必须使用 ListTablesSegmentedAsync
并传入 null 作为 continuationToken
参数。这将继续循环,直到获取所有表为止
更新示例代码
这是列出所有表的伪代码
CloudTableClient tableClient = new CloudTableClient("YOUR CONNECTION STRING");
TableContinuationToken continuationToken = null;
var allTables = new List<CloudTable>();
do
{
var listingResult = await tableClient.ListTablesSegmentedAsync(continuationToken);
var tables = listingResult.Result.ToList();
continuationToken = listingResult.ContinuationToken;
//Add the tables to your allTables
}
while (continuationToken != null);
...
关于c# - 列出 Azure 存储帐户 .NET core 中的所有现有表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51326275/