针对 Azure 表存储的空表查询
我正在使用 Azure 表存储。当我查询一个空表,并且涉及除 PartitionKey 和 RowKey 以外的参数时,出现异常。当我至少有一行时,不会出现异常。如果我只用PartitionKey和RowKey查询空表,就可以了。
我当然不想进行额外的往返来测试表是否为空。人们通常如何解决这个问题?有没有一种高效的方法来快速检查表是否为空?
我正在使用开发存储,因为我刚刚看到在这种情况下开发存储报告了错误,并且该错误在生产中消失了。但是,我不想保留定制代码仅用于开发存储,有没有一个好的方法可以解决这个问题,以便我可以在本地以及生产云环境中运行相同的代码?
I'm using Azure Table Storage. When I query a table that is empty with parameters other than PartitionKey and RowKey involved, I get an exception. When I have at least one row, the exception doesn't appear. If I query the empty table with just PartitionKey and RowKey, it is OK.
I certainly do not want to make an extra round trip to test if the table is empty. How do people normally solve this problem? Is there a performant way to quickly check if the table is empty?
I am using the development storage, as I just saw there are reported errors in this scenario with the development storage and the error goes away in production. However, I do not want to keep customized code just for development storage, is there a good way to get around this, so I could have the same code running local as well as in production cloud environment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过设置 DataServiceContext 解决了这个问题.IgnoreResoureNotFoundException 属性设置为 true。希望这也对其他人有帮助。
I've got this around by setting DataServiceContext.IgnoreResoureNotFoundException property to true. Hope this helps others too.
我无法让 IgnoreResourceNotFoundException 工作并把它踢下去。走了一条“顽皮”的路线,只是因为一张空桌子而陷入了异常。下面截图,欣赏一下...
I couldn't ever get the IgnoreResourceNotFoundException to work and punted it. Took a 'naughty' route and just exception trapped for an empty table. Snip below, enjoy...