If you have an IEnumerable<IGrouping<K, T>>
, say from
var ans = src.GroupBy(s => s.Field);
Is there a better way (rarely used LINQ method/variation) to convert to an IEnumerable<IEnumerable<T>>
then nested Select
s like so:
var ans2 = ans.Select(g => g.Select(s => s));
For those that aren't understanding,
var anst = ans2.Select(g => g.GetType().ReflectedType).All(t => t == typeof(Enumerable));
should return anst == true
.
>` which would show up when doing something like `Skip()` on the groups which would optimize for `List` since that is the actual type. Note that the use of `ReflectedType` on the returned type causes `Enumerable` to be returned for most LINQ operator classes.
>` it is actually also a `IEnumerable>` so your test for whether something is an `IEnumerable>` is disagreeing with the c' compiler on whether something matches that type. Your anst check is a much more strict check of the input and it made no sense to me as to why you *needed* the reflected Types to all be Enumerable.