我知道如何从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(...);
但我想知道:有一种很好的方法来检索整个表吗?
答案 0 :(得分:3)
您可以使用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);