I am trying to translate the following query:
SELECT STATE, COUNT(*)
FROM MYTABLE
GROUP BY STATE;
Into a lambda expression. I am using C# and EntityFramework, however it doesnt seem I can make it work. Here is what I have on my respository so far:
public IEnumerable<object> PorcentajeState(Guid id)
{
return _context.Sates.Where(a => a.Id == id)
.GroupBy(a => a.State)
.Select(n => new { n.StateId , n.Count() });
}
Of course it doesnt compile and I am lost after googling for 2 hours . Could you please help me?
thanks in advance