What do you think of this improvement of Linq's GroupBy method? Linq already has a set of GroupBy methods for enumerable, which returns IEnumerable&lt;IGrouping&lt;TKey, TSource&gt;&gt;. I dislike this return type because it means I have to do a where query everytime I want to find a group. I try to make something that returns a dictionary instead, as below:

 public static class GroupByExtension
    {
        public static Dictionary&lt;TKey, List&lt;TSource&gt;&gt; GroupToDictionary&lt;TSource, TKey&gt;(
            this IEnumerable&lt;TSource&gt; source,
            Func&lt;TSource, TKey&gt; keySelector)
        {
            return source.GroupBy(keySelector).ToDictionary
                (grouping =&gt; grouping.Key, grouping =&gt; grouping.ToList());
        }
    }


I can test it like this

List&lt;int&gt; list = new List&lt;int&gt;() { 1, 2, 33, 4, 20, 43, 21, 93, 26, 31, 113 };
Dictionary&lt;int, List&lt;int&gt;&gt; numbersGroup = list.GroupToDictionary(i =&gt; i / 10); 
//group number by result of division by ten.


So, I can call numbersGroup[1], numbersGroup[3], etc. as opposed to the more clumsy and less efficient Where's clauses if I only have IEnumerable&lt;IGrouping&lt;TKey, TSource&gt;&gt;

IEnumerable&lt;IGrouping&lt;int, int&gt;&gt; numbersGroup2 = list.GroupBy(i =&gt; i / 10);
IGrouping&lt;int, int&gt; group =
            numbersGroup2.Where(grouping =&gt; grouping.Key == 3).First(); 
//and this only returns an IGrouping, not a proper list, 
//and where can be expensive for large list because it uses O(n) IIRC
//the first() could have also been avoided because we know that the keys are unique


What do you think of this code? What drawback do you see? And what is the reason Microsoft use  IEnumerable&lt;IGrouping&lt;TKey, TSource&gt;&gt;
I think the reason it's done this way is to make GroupBy() consistent with the rest of LINQ: everything is as lazy as possible, so that following queries can be efficient.

And there already is a method that does almost the same thing as your GroupToDictionary(), it's called ToLookup().