我如何在WCF数据服务中获得内部联接 [英] How do i get an inner join in a WCF Data Service

查看:44
本文介绍了我如何在WCF数据服务中获得内部联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有2个表,table1和table2,共享键为"id"

Lets say i have 2 tables, table1 and table2, with a shared key "id"

如果我想使用sql对这两个表进行内部联接,我会做类似的事情

if i want an inner join of those two tables using sql, i'd do something like

select id, x, y, z
from table1
inner join table2
on table1.id = table2.id

我现在在表1中得到仅相交出现在表2中的行.

I now get rows in table 1 that only intersect occur in table 2.

我如何在wcf数据服务/odata linq语法中获得等效的内容?

how do i get the equivalent in wcf data service/odata linq syntax?

我期望的是类似的东西

var q = (from t in svc.Table1.Expand("Table2")
    where t.Table2.Any()
    select t) as DataServiceQuery<Table1>;

但这使我想到了关于Any()的例外.
我试过.Join,也不支持. 我已经尝试过.Count,但是也失败了.
.Intersect看起来只需要另一个枚举,所以看起来不像我想要的...

but that gets me an exception about Any().
I've tried .Join and that isn't supported either. I've tried .Count and that fails too.
.Intersect looks like it only takes another enumerable, so that doesn't look like what i want...

我认为我缺少真正明显或简单的东西...

i think i'm missing something really obvious or simple...

编辑:这似乎是推荐答案

看看这种

Take a look at the answers to this type of question. The current version of WCF Data Services (OData) does not support joins even if your underlying data contract does (i.e. if you're layering on top of Entity Framework 4 for instance).

这篇关于我如何在WCF数据服务中获得内部联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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