开发者

How to write linq query for this case?

Suppose I have 3 tables:

TabA(id1, ...., id2, ...)

TabB(id2, ...)

Tab开发者_如何学编程C(id3, ...., id2, ...)

now what I want is to find out all records in TabC, those records should be able to be identified from TabA by its id1. If use SQL, the query would be

Select c.* from TabC c

join TabB b on c.id2 = b.id2

join TabA a on a.id2 = b.id2

Where id1 = inputID

How to write this linq like when I use EF and WCF Ria Service for SL app?

this.ObjectContext.TabC.Where(.....


I normaly do it this way(I find it easier to read):

var q = 
from c in ctx.TabC
from b in ctx.TabB.Where(b=> b.id2 == c.id2)
from a in ctx.TabA.Where(a=> a.id2 == b.id2)
where a.id1 == inputID
select new {....};

I hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜