列出 Azure 存储帐户 .NET 核心中的所有现有表
List all existing tables in Azure Storage Account .NET core
如何获取在我的 Azure 存储帐户中创建的所有现有表?
你以前是这样做的
CloudTableClient tableClient;
IEnumerable<CloudTable> AllTables = tableClient.ListTables();
但是我似乎无法在 CloudTableClient
的实例上调用 ListTables
方法。我正在使用 Microsoft.WindowsAzure.Storage Version 9.3.0
;
EDIT
这是针对 .NET 核心的
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);
.....
如何获取在我的 Azure 存储帐户中创建的所有现有表?
你以前是这样做的
CloudTableClient tableClient;
IEnumerable<CloudTable> AllTables = tableClient.ListTables();
但是我似乎无法在 CloudTableClient
的实例上调用 ListTables
方法。我正在使用 Microsoft.WindowsAzure.Storage Version 9.3.0
;
EDIT
这是针对 .NET 核心的
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);
.....