在c#中加入多个表

时间:2012-09-19 03:54:37

标签: c# asp.net

            var z = from x in resp1.table1
                    join y in resp2.table2 on x.fields equals y.fields
                    select
                    new {y.fields, y.fields1, x.fields2, x.fields3, x.fields4};

我想要一张新桌子,所以基本上我想加入三张或更多桌子,但我不知道如何

2 个答案:

答案 0 :(得分:1)

var z = from x in resp1.table1
        join y in resp2.table2 on x.fields equals y.fields
        join z in resp3.table3 on x.fields equals z.fields
        select
        new {y.fields, y.fields1, x.fields2, x.fields3, x.fields4, z.fields5, z.fields6};

依此类推...但首先检查一下你是really need三联盟!

答案 1 :(得分:0)

var z = from x in resp1.table1
        join y in resp2.table2 on x.fields equals y.fields
        join z in resp3.table3 on x.fields equals z.fields
        select
        new {y.fields, y.fields1, x.fields2, x.fields3, x.fields4, z.fields5};