如何在实体框架中使用Linq加入Master-Detail-Detail Tables

时间:2010-10-11 15:05:54

标签: c# linq entity-framework

我有3张桌子 a,b和c

a.Id,a.code /master
b.Id.b.code,b.aId,c.Id /detail
c.Id,c.code / detail of detail

我将与linq一起加入这三个表并将其显示在网格中。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

var query = from recordA in context.TableA
            join recordB in context.TableB
            on recordA.Id equals recordB.aId
            join recordC in context.TableC
            on recordB.cId equals recordC.Id
            select new 
            {
               // whatever columns are appropriate
            };