1
Vote

Tricky query

description

Hi,
 
I´m working with a grid for MVC (Telerik) and it takes a IQueryable, but I get exceptions when trying to do group by in the grid. I have tracked down the query and verified that the same exception is thrown.
 
Below is the actual query (against the Northwind Customers table)...
 
.OrderBy(p => p.City).Take(10).GroupBy(p => p.City).OrderBy(p => p.Key).Select(p => new { Key = p.Key, ItemCount = p.Count(), HasSubgroups = false, Items = p });
 
...can someone please help me get this query working.
 
It seams to be "ItemCount = p.Count()" thats causing the problem, because it works when i remove that.
 
Thanks in advance.

comments