I've got the following SQL Query which provides me with Month, Year and Count. How can I do the equivalent in LINQ Query Syntax?
SQL
SELECT
MONTH(ExpiryDate) MONTH,
YEAR(ExpiryDate) YEAR,
COUNT(*) COUNT
FROM tblItems
GROUP BY
YEAR(ExpiryDate),
MONTH(ExpiryDate)
Thanks in advance
[UPDATE WORKING ANSWER]
var query = from a in db.tblItems
group a by new
{
((DateTime)a.ExpiryDate).Year,
((DateTime)a.ExpiryDate).Month
} into bca
select new
{
MonthField = bca.Key.Month,
YearField = bca.Key.Year,
CountField = bca.Count(),
};