help converting sql to linq expression with count
Posted
by Philip
on Stack Overflow
See other posts from Stack Overflow
or by Philip
Published on 2010-04-14T18:55:22Z
Indexed on
2010/04/14
19:03 UTC
Read the original article
Hit count: 476
linq-to-sql
|LINQ
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
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
© Stack Overflow or respective owner