我正在使用 Azure 表存储,并且希望能够使用 OData 进行查询。我遇到过Microsoft.Rest.Azure.OData.ODataQuery
类,但我找不到任何如何使用它的示例。
CloudTable
对象允许通过 TableQuery<T>
进行查询对象,那么有没有办法转换 ODataQuery
到 TableQuery
?
我知道早期版本的 Azure 表存储使用了底层 OData API,但我不知道情况是否仍然如此,而且我还没有找到任何详细说明该表是否可以通过 OData 公开的文档。
谁能解释一下如何使用 OData 查询 Azure 表存储 - 最好是通过库?
编辑:
为了清楚起见,我知道表存储公开了一个接受 OData 查询的 REST API;我正在寻找一种以编程方式传递 OData 查询的方法:如果我有 ODataQuery
对象,我如何使用它来查询 CloudTable
对象?
最佳答案
Can anyone explain how to query Azure table storage using OData - ideally through a library?
我们可以从Querying Tables and Entities得到答案。 我们还可以从 Get started with Azure Table storage using .NET 获取 C# 演示代码
The Table service supports the following query options, which conform to the OData Protocol Specification. You can use these options to limit the set of tables, entities, or entity properties returned by a query.
更新:
如果我们使用 fiddler 捕获库请求,我们可以得到库将在发送请求之前构造 OData 查询。
That I'm looking for is a way to pass the OData query programmatically: If I have an ODataQuery object, how can I use this to query a CloudTable object?
目前,Azure表存储不完全支持OData协议(protocol)规范。据我所知,不支持直接使用OdataQuery对象。
您可以给您的 feedback致 azure 团队。
关于c# - 将 ODataQuery 转换为 TableQuery 以使用 OData 查询 Azure 表存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49224951/