我有下面的查询代码,但是它用两个主键之一获取前3个值。我要选择的是最后3行。
仅供参考-我的行键是增加的数字(例如1,2,3,4,5)
var tableUri = "https://mytableuri.table.core.windows.net";
var tableService = AzureStorage.Table.createTableServiceWithSas(tableUri, sasToken);
var tableQuery = new AzureStorage.Table.TableQuery().top(3).where('PartitionKey eq ? or PartitionKey eq ?', partitionA, partitionB);
我想要类似的东西
var tableQuery = new AzureStorage.Table.TableQuery().last(3).where('PartitionKey eq ? and RowKey starts at TotalCount or PartitionKey eq ? and RowKey starts at TotalCount', partitionA, partitionB);
答案 0 :(得分:1)
我发现这篇文章很有用 How to retrieve latest record using RowKey on SO
那我做了什么,因为该文章将时间戳记作为行键,而我使用的是整数。
我将第一行键设置为一个大数字,例如10000000,然后随每个条目递减...
由于这些条目代表两个人之间的聊天消息,因此千万不要在两个人之间碰到这么大的数目。
现在我可以选择top(N),这将是它们之间的最新消息...