我對LINQ非常陌生,我做了很多不成功的嘗試將SQL查詢轉換爲LINQ ..請幫我解決一些問題。什麼是確切的LINQ for this ..謝謝提前。將sql查詢轉換爲linq查詢
//只是整個查詢
select distinct p.IdPatient,p.IdDoc
from patd p (NOLOCK)
left outer join StatusChange sc (NOLOCK)
on sc.IdPatient = p.IdPatient
and sc.IdClinicNumber = 23430
and sc.IdStatus = 'A'
and sc.DateStatusChange > GetDate()
join TrtTyp t ON p.IdTreatmentType = t.IdTreatmentType
and t.TypeModality IN ('H','P')
Where
p.IdType IN ('P','E','M')
and (IsNull(p.IsInactive,0) in (1,0) or sc.IdStatusChange is not null)
and Not Exists(
Select 1
From Expire e (NOLOCK)
Where e.IdPatient = p.IdPatient
)
and p.IdClinicNumber = 23430
對於大查詢,通常是在EF中創建存儲過程或視圖和地址的更好選擇。特別是當「NOLOCK」的特定語法非常重要時,甚至不能使用linq。 –
查看我的回答 –