这可以很好地以最多 1000 个项目的步长对数据进行分页:
var q1 =
(from book in table.CreateQuery<DynamicTableEntity>()
where book.PartitionKey == "TestPartition"
select book).AsTableQuery();
TableContinuationToken continuationToken = null;
do
{
var counter = 0;
var queryResult = q1.ExecuteSegmented(continuationToken);
foreach (var entity in queryResult)
{
Console.WriteLine(entity.Timestamp + " " + ++counter);
}
continuationToken = queryResult.ContinuationToken;
Console.WriteLine("####" + counter);
} while (continuationToken != null);
我真正想做的是先从最旧的项目开始。换句话说,翻阅按 entity.Timestamp 升序排列的项目。此查询不起作用:
var q1 =
(from book in table.CreateQuery<DynamicTableEntity>()
where book.PartitionKey == "TestPartition"
select book).OrderBy(x => x.Timestamp).AsTableQuery();
TableContinuationToken continuationToken = null;
do
{
var counter = 0;
var queryResult = q1.ExecuteSegmented(continuationToken);
foreach (var entity in queryResult)
{
Console.WriteLine(entity.Timestamp + " " + ++counter);
}
continuationToken = queryResult.ContinuationToken;
Console.WriteLine("####" + counter);
} while (continuationToken != null);
由于不支持 OrderBy。我能做些什么来实现这一目标吗?谢谢。
PS:
这可能会有所帮助。但是它首先检索最新的项目,而我想首先检索最旧的项目。