We are using Entity Framework in my project. In one of the requirement I need to query data from multiple tables using left outer joins along with conditions. Here is the SQL script. Can someone provide the lambda expression for this?
SELECT
e.EmployeeId, e.EmployeeFirstName, e.EmployeeLastName,
s.SkillId, s.SkillName,
c.CertificateId, c.CertificateName, c.ExpiryDate
FROM
[dbo].[Employee] AS e
LEFT OUTER JOIN
[dbo].[EmployeeSkill] AS s ON e.EmployeeId = s.EmployeeId
AND s.IsActiveSkill = 1
LEFT OUTER JOIN
[dbo].[EmployeeCertification] AS c ON e.EmployeeId = c.EmployeeId
AND c.IsActiveCertification = 1
AND c.ExpiryDate < GETUTCDATE() + 30
WHERE
e.DepartmentId = 1
AND e.IsActiveEmployee = 1
You can use GroupJoin. It has same functionality as left outer join in SQL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.