title: Creating ILookups
body: <p>I've got an ILookup generated by some complicated expression. Let's say it's a lookup of people by last name. (In our simplistic world model, last names are unique by family)</p>
  
  <pre><code>ILookup&lt;string, Person&gt; families;
  </code></pre>
  
  <p>Now I've got two queries I'm interested in how to build.</p>
  
  <p><em>First, how would I filter by last name?</em></p>
  
  <pre><code>var germanFamilies = families.Where(family =&gt; IsNameGerman(family.Key));
  </code></pre>
  
  <p>But here, <code>germanFamilies</code> is an <code>IEnumerable&lt;IGrouping&lt;string, Person&gt;&gt;</code>; if I call <code>ToLookup()</code> on it, I'd best bet would get an <code>IGrouping&lt;string, IGrouping&lt;string, Person&gt;&gt;</code>. If I try to be smart and call <code>SelectMany</code> first I'd end up with the computer doing a lot of unnecessary work. How would you convert this enumeration into a lookup easily?</p>
  
  <p><em>Second, I'd like to get a lookups of adults only.</em></p>
  
  <pre><code>var adults = families.Select(family =&gt;
           new Grouping(family.Key, family.Select(person =&gt;
                 person.IsAdult())));
  </code></pre>
  
  <p>Here I'm faced with two problems: the <code>Grouping</code> type doesn't exist (except as an internal inner class of <code>Lookup</code>), and even if it did we'd have the problem discussed above.</p>
  
  <p>So, apart from implementing the ILookup and IGrouping interfaces completely, or make the computer do silly amounts of work (regrouping what has already been grouped), is there a way to alter existing ILookups to generate new ones that I missed?</p>