将以下linq代码转为sql server var query = from a in _AppointmentInfoDAL.Table.Where(a => a.Code == appointmentCode) join ad in _AppointmentDetailDAL.Table.Where(a => hisKeys.Contains(a.HisKey)) on a.Code equals ad.MasterCode join d in _InspectionItemDetailDAL.Table on ad.ItemCode equals d.Code join h in _HisBillInfoDAL.Table.Where(a => a.Status == 0) on ad.HisKey equals h.ItemId join pn in _PartNameDAL.Table on ad.PartCode equals pn.Code into pn2 from pn3 in pn2.DefaultIfEmpty() from i3 in _InspectionItemNoteDAL.Table.Where(p => p.InspItemCode == a.InspectionCode && (p.Type == 0 || p.Type.ToString() == a.PatientType)).DefaultIfEmpty() join p in _PatientInfoDAL.Table on a.PatientCode equals p.Code join e in _ExamineRoomInfoDAL.Table on a.RoomCode equals e.Code join it in _InspectionItemDAL.Table on d.InspItemCode equals it.Code join di in _DepartmentInfoDAL.FindList() on e.DeptCode equals di.Code join ph in _PhysicalRoomInfoDAL.Table on a.PhysicalRoomCode equals ph.Code into ph2 from ph3 in ph2.DefaultIfEmpty()
时间: 2024-02-15 15:28:24 浏览: 89
linq 转换 sql
SELECT *
FROM AppointmentInfo a
INNER JOIN AppointmentDetail ad ON a.Code = ad.MasterCode
INNER JOIN InspectionItemDetail d ON ad.ItemCode = d.Code
INNER JOIN HisBillInfo h ON ad.HisKey = h.ItemId
LEFT OUTER JOIN PartName pn ON ad.PartCode = pn.Code
LEFT OUTER JOIN InspectionItemNote i3 ON i3.InspItemCode = a.InspectionCode AND (i3.Type = 0 OR CAST(i3.Type AS varchar) = a.PatientType)
INNER JOIN PatientInfo p ON a.PatientCode = p.Code
INNER JOIN ExamineRoomInfo e ON a.RoomCode = e.Code
INNER JOIN InspectionItem it ON d.InspItemCode = it.Code
INNER JOIN DepartmentInfo di ON e.DeptCode = di.Code
LEFT OUTER JOIN PhysicalRoomInfo ph3 ON a.PhysicalRoomCode = ph3.Code
WHERE a.Code = appointmentCode AND hisKeys.Contains(ad.HisKey) AND h.Status = 0
阅读全文