我对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。 –
查看我的回答 –