Filter and collections in OData

徘徊边缘 提交于 2019-12-11 11:21:51

问题


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')

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.


回答1:


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) 

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



来源:https://stackoverflow.com/questions/25673213/filter-and-collections-in-odata

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!