I'm trying to get my brain around LINQ Group By and I'm making headway, with one small flaw in my knowledge. I would like to group by multiple columns which I know I can do with new {} and some fields. Only issue is that I may or may not want to include them, based on some querystring values.
I've got this:
var groupByResults = items.GroupBy(i => new
{
i.Product.Season.SeasonID,
i.SourceLocation.LocationID,
i.Product.Brand.BrandID,
i.Product.Category.CategoryID,
i.Size.SizeID
});
I might want my anonymous object to only have the first field, or the last two, or whatever - depends which tickboxes have been ticked in the browser. I'm thinking ExpandoObject but I'm struggling how to get the relationship in there with regards to the 'i' from i => .....
As with everything I ask, it's just that I haven't figured out the right phrase for Google. Any help would be greatly appreciated.