Linq to Entities group query giving list of results in each group
c#, entity-framework, linq, linq-to-entities
Solution
If you want to get List of Ids for each group then you have to select `x.Select(r => r.Id)` like:
var result = Items.GroupBy(x => new { x.Size, x.Type })
.Select(x => new
{
Key = x.Key,
Ids = x.Select(r => r.Id)
});
Problem
If I have a set of entities with 3 properties (Id, Type, Size) all of which are strings. Is there a way using Linq to Entities where I can do a group query which gives me the `Size` + `Type` as the key and then a list of the related Id's for that `Size` + `Type`? Example below of getting the count: ``` Items.GroupBy(x => new { x.Size, x.Type}) .Select(x => new { Key = x.Key, Count = x.Count() }) ``` but I am looking to get a list of the Ids for each grouping? I am looking to see if it is possible using Linq-to-EF before I decide to iterate through this in code and build up the result instead.