【发布时间】:2012-11-21 09:39:38
【问题描述】:
我对 LINQ 很陌生,我做了很多将 SQL 查询转换为 LINQ 的尝试都失败了。请帮我解决一些问题。确切的 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。
标签: linq sql-to-linq-conversion