I have to form a linq query with select, count and select statement
My table looks like this
Date Name
2015-04-25 xxy
2015-04-25 pap
2015-04-25 sms
2014-07-12 bljoe
2014-07-12 olk
I want the result similar to this
Date Count
2015-04-25 3
2014-07-12 2
My sql query will be like this :
select t.date, COUNT(k.Name)
from table t
group by t.date
But I dont know how my linq query should be :
I tried like this. But it returned exception
var result = (from ka in _db.table
group t by new {t.Date} into g
select new
{
Date = g.Key,
Count = g.FirstOrDefault().Name.Count()
}).ToList();