If I have used LINQ's GroupBy() method to create a grouped enumeration, is it possible to regroup that result under another key system? That is, if I grouped all of the objects by property X for one part of the code, is it possible to subsequently group that collection by property Y of property X at a later point in the code?
+2
A:
I didn't read your question, but this works:
var groupedByProperty1 = myEnumerable.GroupBy(x => x.Property1);
var groupedByProperty2 = groupedByProperty1.SelectMany(g => g)
.GroupBy(x => x.Property2);
Is that what you're looking for by any chance?
dtb
2010-06-28 14:44:54
As it turns out, this is exactly what I'm looking for. Thanks a bunch!
ccomet
2010-06-28 15:07:54