How do I convert this query into LINQ? -
select * procedurelookup proclookup inner join (select patientprocedures.pp_procedureid, count(*) proccount (patientprocedures inner join treatments on patientprocedures.pp_treatmentid = treatments.ts_treatmentid) year(treatments.ts_date) = year(getdate()) group patientprocedures.pp_procedureid) cyearproc on proclookup.pl_procedureid = cyearproc.pp_procedureid order proccount desc;
here procedurelookup
, treatments
, patientprocedures
tables.
here linq query.
var result = (from proclookup in db.procedurelookup join cyearproc in ( p in db.patientprocedures join t in db.treatments on p.pp_treatmentid equals t.ts_treatmentid t.ts_date.year == datetime.now.year group p p.pp_procedureid g select new { pp_procedureid = g.key, proccount = g.count() } ) on proclookup.pl_procedureid equals cyearproc.pp_procedureid orderby cyearproc.proccount descending select new { // columns pp_procedureid = proclookup.pp_procedureid, proccount = cyearproc.proccount }).tolist();
Comments
Post a Comment