OData中的过滤器和集合 [英] Filter and collections in OData

查看:124
本文介绍了OData中的过滤器和集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与Azure最近以预览形式发布的搜索服务有关.我试图弄清楚如何对集合使用OData的过滤器.我知道我可以做到:

This is related to Azure's recently launched search service that is currently in preview form. I'm trying to figure out how to use OData's filter with collections. I know that I can do this:

$filter=Products/any(p: p eq 'WidgetA')

,它将按WidgetA过滤产品"集合.我要弄清楚的是如何指定WidgetA或WidgetB.我知道我可以做到:

which will filter the Products collection by WidgetA. What I am trying to figure out is how to specify WidgetA OR WidgetB. I know that I can do this:

$filter=Products/any(p: p eq 'WidgetA') or Products/any(p: p eq 'WidgetB')

但是认为这样做必须有一种更优雅或更短的方式.

but thought there must be a more elegant or shorter way of doing this.

推荐答案

不幸的是,据我所知没有.满足您要求的操作员位于中",但协议中没有:

Unfortunately, there is no as far as I know. The operator that addresses your requirement is 'in' but there is no in the protocol: http://docs.oasis-open.org/odata/odata/v4.0/os/part2-url-conventions/odata-v4.0-os-part2-url-conventions.html

还有一件事:范围变量后面应该有一个属性:

One more thing: there should be a property follows the range variable:

http://host/service/Orders?$filter=Items/any(d:d/Quantity gt 100) 

在您的情况下,应为"p/Name eq'WidgetA'"或其他一些属性.

in your case it should be "p/Name eq 'WidgetA'" or some other properties.

这篇关于OData中的过滤器和集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆