需要在linq中编写2个外连接

时间:2014-11-18 09:57:49

标签: c# linq

我需要使用linq编写以下查询。非常感谢任何帮助。

select
        r1.rID,
        name,
        uName,
        001 aID,
        nvl(uValue, 0) uValue
    from
        r1,
        r2,
        l
    where
        r1.rID = r2.rID 
        and r1.rID = l.rID(+) 
        and 001 = l.aID(+)
    order by
        r1.rID

1 个答案:

答案 0 :(得分:0)

它应该是这样的:

var result = (from  r1 in db.r1
              join  r2 in db.r2 on r1.rID equals r2.rID
              join  l  in db.l  on r1.rID equals l.rID
              where l.aID == "001"
              orderby r1.rID 
              select new {
                  rID    = r1.rID,
                  Name   = r1.name,
                  UName  = r1.uName,
                  aID    = "001",
                  UValue = nvl(r.uValue)
              }).ToList();