SQL 转 LINQ, 多left join ,在线等结贴

Error_Code 2010-02-10 11:58:30

SELECT Patients.*, CurrentSurgeries.*,Fac_PreopChecklists.*
FROM
(Patients left join Pt_CurrentSurgeries on Patients.PatientID = Pt_CurrentSurgeries.PatientID)
left join Fac_PreopChecklists on Fac_PreopChecklists.Pt_CurrentSurgeryID=Pt_CurrentSurgeries.Pt_CurrentSurgeryID
left join CurrentSurgeries on Pt_CurrentSurgeries.CurrentSurgeryID = CurrentSurgeries.CurrentSurgeryID, Pt_Forms, Forms
WHERE (Pt_CurrentSurgeries.StatusID>0 OR Pt_CurrentSurgeries.StatusID is null)
AND (CurrentSurgeries.SurgeryDate>=GETDATE() or CurrentSurgeries.SurgeryDate is null)
AND Patients.PatientID = Pt_Forms.PtID
AND Pt_Forms.FormID = Forms.FormID
AND Forms.FacilityID=12
AND (Patients.FirstName like '%sdf%' OR Patients.LastName like '%sdf%')
...全文
121 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-02-10
  • 打赏
  • 举报
回复
var q =
from e in db.Employees
join o in db.Books on e.EmployeeID equals o.EmployeeID into b
from x in b.DefaultIfEmpty()
select new
{
e.ID,
e.Name,
o.BookName
};


Error_Code 2010-02-10
  • 打赏
  • 举报
回复
刚发现Linq to entities 不能DefaultIfEmpty()

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧