How to get an internal connection in a WCF data service

Suppose I have 2 tables, table1 and table2, with the common key "id"

If I need an internal join of these two tables using sql, I would do something like

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

Now I get the rows in table 1 that intersect only in table 2.

how to get equivalent in linq wcf data service / odata syntax?

I expect something like:

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

but that makes me an exception to Any() .
I tried .Join and this is also not supported. I tried .Count , and that didn't work either.
.Intersect looks like it takes up another enumeration, so it doesn't look like what I want ...

I think I am missing something really obvious or simple ...

Edit: this looks like a duplicate How to use OData Expand as a SQL join?

0
source share
4 answers

Take a look at the answers to this question . The current version of WCF Data Services (OData) does not support connections, even if your underlying data contract does (for example, if you, for example, perform a hierarchy on Entity Framework 4).

+2
source

Currently, the OData protocol (and therefore WCF data services) does not support any / all operations. It also does not support arbitrary joins, although some joins may be expressed as navigational ones. Your request is currently not supported, but we are exploring adding support for any / all operations. Take a look at this suggestion if it satisfies your needs: http://www.odata.org/blog/support-for-any-and-all

+1
source

Recent versions of WCF data services now support Any / All. See What's New in WCF 5.0 Data Services

+1
source

Is WCF playing here? To link two objects from two tables / lists, I would do the following:

 var result = from o1 in Table1 join o2 in Table2 on o2.id equals o1.id 
0
source

All Articles