我想通过使用linq编写左连接,但它给出了一个错误。这是SQL代码:如何使用左连接linq
Select
Case s.StudentID
When 1000 Then s.Amount
End As Amount
From Student s
Left Join Course cOn c.Time = s.ForDate And c.StudentID= s.ID And s.Amount= 1000
这一个是我试过的代码,但它给出了一个错误的左连接:
from s in Student
join c in Course
on new {s.ForDate , s.ID}
equals new { c.Time, c.StudentID}
into inj
from i in inj.DefaultIfEmpty()
where s.Amount= 1000
确保s.ForDate和c.Time是同一类型的,或者你需要使用强制 – Rise
它给出错误的s.Amount = 1000。我也试过inj.Amount但仍然给出错误 – phi
我错过了where子句中的=运算符。再次检查它 – Rise