我有一些来自Azure Tables的选择数据的代码:
IQueryable<DataEntity> data =
(from e in table.CreateQuery<DataEntity>()
where
String.Compare(e.PartitionKey,
string.Format("{0:0000000000000000000}", start),
StringComparison.Ordinal) >= 0 &&
String.Compare(e.PartitionKey, string.Format("{0:0000000000000000000}", end),
StringComparison.Ordinal) <= 0
select e);
data.AsTableQuery().Execute();
工作正常,但只返回1000件物品,我不知道如何退货。 我找到了这段代码:
do
{
TableQuerySegment<DataEntity> tableQueryResult =
await table.ExecuteQuerySegmentedAsync(tableQuery, continuationToken);
continuationToken = tableQueryResult.ContinuationToken;
allCount += tableQueryResult.Results.Count;
} while (continuationToken != null);
但我不知道如何使用 ExecuteQuerySegmentedAsync 重新制作代码。 以及如何获得 ContinuationToken ? 请帮我解决这个问题。
答案 0 :(得分:3)
试试这段代码:
exec(function () { that.result += "Test 2.1"; }, function (error) { that.result += "Test 2.2: " + error; }, "XXXBarcodeScanner", "Enable", []);
基本上,您需要调用ExecuteSegmented
方法而不是 var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
var tableClient = account.CreateCloudTableClient();
var table = tableClient.GetTableReference("Address");
TableContinuationToken token = null;
IQueryable<DynamicTableEntity> data = (
from e in table.CreateQuery<DynamicTableEntity>()
select e
);
long entitiesCount = 0;
do
{
var result = data.AsTableQuery().ExecuteSegmented(token);
token = result.ContinuationToken;
var entities = result.Results;
entitiesCount += entities.Count;
Console.WriteLine(entitiesCount + " entities fetched");
} while (token != null );
。