wcf-data-services:带过滤器的多对多

发布于 2025-01-05 00:55:04 字数 348 浏览 5 评论 0 原文

我的 wcf-data-service 中有两个实体:

RequestServer

一个请求可以分配给多个服务器,而服务器上可以有多个请求。

我想查询分配给特定数量服务器的所有请求(在本例中:分配给 ID=1 ID=2 的服务器的所有请求),例如:

http ://localhost/MyDataService/Request?$filter=(Server.ID eq 1 and Server.ID eq 2)

但是这当然行不通。 odata 可以做到这一点吗?如果没有:有解决方法吗?

I have two enities in my wcf-data-service:

Request and Server

one Request can be assigned to multiple servers, whereas on server can have multiple requests.

I want to query all requests that are assigned to a specific number of servers (in this example: all requests that are assigned to the servers with ID=1 and ID=2) like:

http://localhost/MyDataService/Request?$filter=(Server.ID eq 1 and Server.ID eq 2)

However this does of course not work. Is this possible with odata? If not: Is there a workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美人迟暮 2025-01-12 00:55:04

对于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文