title: GroupBy multiple fields but return IGrouping<string, MyEntity>
body: <p>I have a standard workflow that processes <code>IGrouping&lt;string, MyEntity&gt;</code> instances. I have always grouped by a single field therefore I have had no issues with that. Now however I have a new requirement where I have to group by multiple fields to generate the groups but I thought I could still reuse the same process by somehow have my key generated by the contatenation of the &quot;fields.ToString()&quot; value if that makes sense.</p>
  <p>In my case, at the moment I'm grouping by <code>MyEntity.ExternalKeyId1</code> and the values are &quot;id1&quot;, &quot;id2&quot;, etc. Now I'd like to group by &quot;MyEntity.ExternalKeyId1_MyEntity.ExternalKeyId2&quot; having the values like &quot;id1_id11&quot;, &quot;id1_id12&quot; and so on.</p>
  <p>I have seen you can achieve part of this by using anonymous types to perform the actual grouping:</p>
  <pre><code>var groups = myEntities.GroupBy(m =&gt; new {m.ExternalKeyId1, m.ExternalKeyId2});
  </code></pre>
  <p>That breaks the fact I STILL want to use the IGrouping&lt;string, MyEntity&gt; that's why I thought that you could do something like <code>.Select(x =&gt; new IGrouping...)</code> or <code>ToIGrouping(...</code> because I cannot do <code>.Select(x =&gt; new {Key =$&quot;{x.Key.ExternalKeyId1}_{x.Key.ExternalKeyId2}&quot;...</code></p>
  <p>Is that possible or do I have to re-implement that bit?</p>
  <p><strong>UPDATE:</strong></p>
  <p>Looks like doing <code>GroupBy(x =&gt; $&quot;{x.ExternalKeyId1}_{x.ExternalKeyId2}&quot;)</code> does the trick</p>