Azure tables:检索整个 table

Azure tables: Retrieve entire table

我知道如何从 Azure table 中获取一些 table 实体,如下所示:

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(...);

但我想知道:是否有一种很好的方法来检索整个 table?

您可以使用 TableQuery 来获取整个 table。

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);