SubSelects in LINQ
What a challenge I was facing trying to figure out how to solve this problem in LINQ.. but i did it .. and am sharing. SQL query: Select Distinct o.ConceptCode, u.firstname, u. lastname , (select count(*) from callLead where calldate ='2014-09-02' and conceptcode=O.conceptcode and userid=O.userid) 'DailyTotal' ,(select count(*) from callLead where calldate between '2014-09-01' and '2014-09-05' and conceptcode=O.conceptcode and userid=O.userid) 'WTD' ,(select count(*) from callLead where datepart(m,calldate)=9 and conceptcode=O.conceptcode and userid=O.userid) 'MTD' ,(select count(*) from callLead where datepart(yyyy,calldate)=2014 and conceptcode=O.conceptcode and userid=O.userid) 'YTD' from callLead O join users u on o.userid=u.userid The LINQ Conversion: The LINQ version is much prettier actually var rptSummary = (from e in SalesEntities.CallLeads ...