我有两张桌子
PatientEncounterDemo
和PatientMaster
PatientEncounterDemo
:
PateientID(F.K int),
DoctorId( F.K int),
ProcedureName
PatientMaster:
PatientId(P.K identity)
PatientFirstName(varchar(50)),
PatientLastName(varchar(50)),
PatientDOB
我需要提取 PatientName(patientFirstName_+patientLastName)、patientDOB 和分配给特定患者的程序计数(患者可以分配许多程序)
我为该结果编写了 SQL 查询:
//This puts the join inside count-
select distinct PatientFirstName+ ' ' + PatientLastName as PatientName,PatientDOB,COUNT(ProcedureName) as [Proc Count] from
(
select distinct p.PatientFirstName,p.PatientLastName,p.PatientDOB,e.ProcedureName
from PatientMaster p,PatientEncounterDemo e
where p.PatientId=e.PatientId and e.DoctorId=1
)as mytable group by PatientFirstName,PatientLastName,PatientDOB
但是,我正在努力通过 linq 查询来做到这一点。请提出一些建议..!!