小编cpp*_*rog的帖子

LINQ中多个左连接的正确语法?

我试图找出LINQ多个左连接的语法,但我收到错误:The name 'c' is not in scope on the left side of 'equals'. Consider swapping the expressions on either side of 'equals'.

我已经尝试过交换,如果我这样做,它会使'c'和'd'都有"not in scope"错误.

            var result = 
                    from a in db.tableA

                    join b in db.tableB //first join (inner join)
                        on a.field1 equals b.field1

                    join c in db.tableC //second join (left join)
                        on a.field1 equals c.field1
                            into left_one

                    join d in db.tableD   //third join (left join)
                        on c.field2 equals d.field2
                        // ^ here
                            into left_two


                    where a.field1 …
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework join left-join

4
推荐指数
1
解决办法
1556
查看次数

标签 统计

c# ×1

entity-framework ×1

join ×1

left-join ×1

linq ×1