wcf-data-services:带过滤器的多对多
我的 wcf-data-service 中有两个实体:
Request
和 Server
一个请求可以分配给多个服务器,而服务器上可以有多个请求。
我想查询分配给特定数量服务器的所有请求(在本例中:分配给 ID=1 和 ID=2 的服务器的所有请求),例如:
http ://localhost/MyDataService/Request?$filter=(Server.ID eq 1 and Server.ID eq 2)
但是这当然行不通。 odata 可以做到这一点吗?如果没有:有解决方法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 RTM 位,这是不可能的。但在 OData V3 中,我们添加了允许这样做的任何/所有运算符。像这样的东西应该可以工作:
/Requests?$filter=Servers/any(s: s/ID eq 1) 和 Servers/any(s: s/ID eq 2)
您可以使用最新的 CTP 尝试此操作: http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and- silverlight-4.aspx
如果您需要保留在 V2 上,您可以编写一个服务操作来为您执行此操作。
With the RTM bits this is not possible. But in OData V3 we're adding any/all operators which should allow this. Something like this should work:
/Requests?$filter=Servers/any(s: s/ID eq 1) and Servers/any(s: s/ID eq 2)
You can try this with the latest CTP: http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and-silverlight-4.aspx
If you need to remain on V2 you can write a service operation to perform this operation for you.