Azure表:检索整个表
本文关键字:Azure 检索 | 更新日期: 2023-09-27 17:59:16
我知道如何从Azure表中获取一些表实体,如下所示:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting(...);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("table");
TableOperation retrieveOperation = TableOperation.Retrieve(...);
TableResult retrievedResult = table.Execute(retrieveOperation);
或
TableQuery<MyEntity> query = new TableQuery<MyEntity>().Where(TableQuery.GenerateFilterCondition(...);
但我想知道:有没有一种很好的方法可以检索整个表?
您可以使用TableQuery
来获取整个表。
var list = new List<MyEntity>();
var table = tableClient.GetTableReference("table");
var tableQuery = new TableQuery<UserEntity>();
TableContinuationToken continuationToken = null;
do
{
var query = await table.ExecuteQuerySegmentedAsync(
tableQuery, continuationToken).ConfigureAwait(false);
list.AddRange(query.Results);
continuationToken = query.ContinuationToken;
} while (continuationToken != null);