我如何在WCF数据服务中获得内部联接 [英] How do i get an inner join in a WCF Data Service
问题描述
让我们说我有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...