help converting sql to linq expression with count
- by Philip
I am trying to convert the following SQL into a LINQ expression
SELECT COUNT(ID) AS Count, MyCode
FROM dbo.Archive
WHERE DateSent=@DateStartMonth AND DateSent<=@DateEndMonth
GROUP BY MyCode
and I have been trying to follow this webpage as an example
http://stackoverflow.com/questions/606124/converting-sql-containing-top-count-group-and-order-to-linq-2-entities
I got this so far but I am stuck on understanding the new part
var res=(from p in db.Archives
where (p.DateSent>= dateStartMonth) && (p.DateSent< dateToday)
group p by p.MyCode into g
select new { ??????MyCode = g.something?, MonthlyCount= g.Count() });
Thanks in advance for helping
greatly appreciated
Philip