如何使用 Azure 表存储选择 RowKey 范围?
我想使用 PrimaryKey 查询我的 azure 表存储,另外我想检查我的 RowKey 是否在一个范围内。例如范围 02001 到 02999
有人能告诉我如何做到这一点吗?我了解如何使用简单的查询 PK:
where fooEntiy.PartitionKey == partition
但我不知道如何查询 fooEntity.RowKey。
另外,如果我通过指定范围来执行此操作,那么它是否仍会检索该分区的所有条目,然后检查它们是否与范围匹配?
谢谢你的建议,
真理子
I would like to query my azure tablestorage using PrimaryKey plus I would like to check my RowKey is within a range. For example the range 02001 to 02999
Can someone tell me how I can do this? I understand how to query the PK with a simple:
where fooEntiy.PartitionKey == partition
but I don't know how I can query fooEntity.RowKey.
Also if I do this by specifying a range then will it still retrieve all the entries for that partition and then check to see if they match the range?
Thank you for your advice,
Mariko
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的查询可能如下所示:
这应该返回
lowerBoundRowKey
和upperBoundRowKey
之间的所有项目,包括这些值(如果您不希望它包含在内,只需使用 > 和 < 而不是 >= 和 <=)。除此之外,您不需要进行任何其他过滤。
看起来您已经用前导零填充了存储在 RowKey 中的数字,这是一件好事,因为该范围将是词法范围,而不是数字范围。
例如,使用
lowerBoundKey = 10
和upperBoundKey = 100
运行此查询将不会返回 RowKey 为 20 的项目。但是,如果您用零填充它
lowerBoundKey = 00010
和upperBoundKey = 00100
将返回 RowKey 为 00020 的项目。Your query could look something like this:
This should return all of the items between the
lowerBoundRowKey
and theupperBoundRowKey
including those values (if you don't want it to be inclusive, just use > and < rather than >= and <=).You will not need to do any other filtering than this.
It looks like you're already padding your numbers that you're storing in the RowKey with leading zeros which is a good thing as this range will be a lexical range, not a numeric range.
e.g. running this query with
lowerBoundKey = 10
andupperBoundKey = 100
will not return an item with a RowKey of 20.If you pad it with zeros however
lowerBoundKey = 00010
andupperBoundKey = 00100
will return an item with a RowKey of 00020.这将使实体使用指定范围的 RowKey 值和指定的 PartitionKey:
" PartitionKey eq 'yourpartitonKey value' and (RowKey gt '02001' and RowKey lt '02999') "
查找更多信息 此处 和 此处。
希望这有帮助。
This will bring entities using the specified range of RowKey values with specified PartitionKey:
" PartitionKey eq 'your partitonKey value' and (RowKey gt '02001' and RowKey lt '02999') "
Find more information here and here.
Hope this helps.