我使用的系统在Employees表和TimesheetHeader表中有两个表。 TimesheetHeader表具有employees表的主键作为外键。 SQL中的查询工作正常,但我需要它是C#.net将识别的LINQ查询。
SELECT e.Employee, e.Name, t.Status FROM Employees e LEFT JOIN TimesheetHeader t ON
e.Employee=t.EmployeeID WHERE e.unionID='CUPE 859' AND e.LabourClass='5' AND
e.Active=1 AND e.RoleID>=3 AND (t.TimesheetDate='02/09/2011' OR ISNULL(t.TimesheetDate,'')='')
非常喜欢这里的任何帮助。
答案 0 :(得分:0)
类似的东西:
DateTime someDate = new DateTime(2011, 09, 02)
from e in db.Employees
join th in db.TimeHeaders.Where(t => t.TimesheetDate == null || t.TimeSheetDate == someDate)
into TimeSheetHeaders
where e.unionID = '' && e.LabourClass == '5' && (other conditions go here)
select new {Employee = e, TimeSheetHeaders}