# C1.LiveLinq.IndexedQueryExtensions.GroupBy

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_LiveLinq_IndexedQueryExtensions_GroupBy_" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy*">GroupBy Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_LiveLinq_IndexedQueryExtensions_GroupBy_" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy*"></a>
<h4 id="C1_LiveLinq_IndexedQueryExtensions_GroupBy__4_C1_LiveLinq_Indexing_IIndexedSource___0__System_Linq_Expressions_Expression_System_Func___0___1___System_Linq_Expressions_Expression_System_Func___0___2___System_Linq_Expressions_Expression_System_Func___1_System_Collections_Generic_IEnumerable___2____3___" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy``4(C1.LiveLinq.Indexing.IIndexedSource{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.Linq.Expressions.Expression{System.Func{``1,System.Collections.Generic.IEnumerable{``2},``3}})">GroupBy&lt;TSource, TKey, TElement, TResult&gt;(IIndexedSource&lt;TSource&gt;, Expression&lt;Func&lt;TSource, TKey&gt;&gt;, Expression&lt;Func&lt;TSource, TElement&gt;&gt;, Expression&lt;Func&lt;TKey, IEnumerable&lt;TElement&gt;, TResult&gt;&gt;)</h4>
<div class="markdown level1 summary"><p>Groups the elements of a collection according to a specified key selector function and creates a result value
from each group and its key. The elements of each group are projected by using a specified function.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static IIndexedSource&lt;TResult&gt; GroupBy&lt;TSource, TKey, TElement, TResult&gt;(this IIndexedSource&lt;TSource&gt; source, Expression&lt;Func&lt;TSource, TKey&gt;&gt; keySelector, Expression&lt;Func&lt;TSource, TElement&gt;&gt; elementSelector, Expression&lt;Func&lt;TKey, IEnumerable&lt;TElement&gt;, TResult&gt;&gt; resultSelector)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GroupBy(Of TSource, TKey, TElement, TResult)(source As IIndexedSource(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), elementSelector As Expression(Of Func(Of TSource, TElement)), resultSelector As Expression(Of Func(Of TKey, IEnumerable(Of TElement), TResult))) As IIndexedSource(Of TResult)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;TSource&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>An <a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource&lt;T&gt;</a> whose elements to group</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;TSource, TKey&gt;&gt;</td>
      <td><span class="parametername">keySelector</span></td>
      <td><p>A function to extract the key for each element.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;TSource, TElement&gt;&gt;</td>
      <td><span class="parametername">elementSelector</span></td>
      <td><p>A function to map each source element to an element in the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping&lt;TKey, TElement&gt;</a>.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-3">Func</a>&lt;TKey, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;TElement&gt;, TResult&gt;&gt;</td>
      <td><span class="parametername">resultSelector</span></td>
      <td><p>A function to create a result value from each group.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;TResult&gt;</td>
      <td><p>A collection of elements of type <i>TResult</i> where each element represents a projection over a group and its key.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">TSource</span></td>
      <td><p>The type of the elements of <i>source</i>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TKey</span></td>
      <td><p>The type of the key returned by <i>keySelector</i>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TElement</span></td>
      <td><p>The type of the elements in the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping&lt;TKey, TElement&gt;</a>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TResult</span></td>
      <td><p>The type of the result value returned by <i>resultSelector</i></p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_LiveLinq_IndexedQueryExtensions_GroupBy_" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy*"></a>
<h4 id="C1_LiveLinq_IndexedQueryExtensions_GroupBy__3_C1_LiveLinq_Indexing_IIndexedSource___0__System_Linq_Expressions_Expression_System_Func___0___1___System_Linq_Expressions_Expression_System_Func___0___2___" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy``3(C1.LiveLinq.Indexing.IIndexedSource{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Linq.Expressions.Expression{System.Func{``0,``2}})">GroupBy&lt;TSource, TKey, TElement&gt;(IIndexedSource&lt;TSource&gt;, Expression&lt;Func&lt;TSource, TKey&gt;&gt;, Expression&lt;Func&lt;TSource, TElement&gt;&gt;)</h4>
<div class="markdown level1 summary"><p>Groups the elements of a collection according to a specified key selector function and projects the elements for each group by using a specified function.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static IIndexedSource&lt;IGrouping&lt;TKey, TElement&gt;&gt; GroupBy&lt;TSource, TKey, TElement&gt;(this IIndexedSource&lt;TSource&gt; source, Expression&lt;Func&lt;TSource, TKey&gt;&gt; keySelector, Expression&lt;Func&lt;TSource, TElement&gt;&gt; elementSelector)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GroupBy(Of TSource, TKey, TElement)(source As IIndexedSource(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), elementSelector As Expression(Of Func(Of TSource, TElement))) As IIndexedSource(Of IGrouping(Of TKey, TElement))</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;TSource&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>An <a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource&lt;T&gt;</a> whose elements to group</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;TSource, TKey&gt;&gt;</td>
      <td><span class="parametername">keySelector</span></td>
      <td><p>A function to extract the key for each element.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;TSource, TElement&gt;&gt;</td>
      <td><span class="parametername">elementSelector</span></td>
      <td><p>A function to map each source element to an element in the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping&lt;TKey, TElement&gt;</a>.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping</a>&lt;TKey, TElement&gt;&gt;</td>
      <td><p>A collection of <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping&lt;TKey, TElement&gt;</a> objects each containing a collection of objects of type
<i>TElement</i> and a key.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">TSource</span></td>
      <td><p>The type of the elements of <i>source</i>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TKey</span></td>
      <td><p>The type of the key returned by <i>keySelector</i>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TElement</span></td>
      <td><p>The type of the elements in the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping&lt;TKey, TElement&gt;</a>.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_LiveLinq_IndexedQueryExtensions_GroupBy_" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy*"></a>
<h4 id="C1_LiveLinq_IndexedQueryExtensions_GroupBy__3_C1_LiveLinq_Indexing_IIndexedSource___0__System_Linq_Expressions_Expression_System_Func___0___1___System_Linq_Expressions_Expression_System_Func___1_System_Collections_Generic_IEnumerable___0____2___" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy``3(C1.LiveLinq.Indexing.IIndexedSource{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Linq.Expressions.Expression{System.Func{``1,System.Collections.Generic.IEnumerable{``0},``2}})">GroupBy&lt;TSource, TKey, TResult&gt;(IIndexedSource&lt;TSource&gt;, Expression&lt;Func&lt;TSource, TKey&gt;&gt;, Expression&lt;Func&lt;TKey, IEnumerable&lt;TSource&gt;, TResult&gt;&gt;)</h4>
<div class="markdown level1 summary"><p>Groups the elements of a collection according to a specified key selector function and creates a result value from each group and its key.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static IIndexedSource&lt;TResult&gt; GroupBy&lt;TSource, TKey, TResult&gt;(this IIndexedSource&lt;TSource&gt; source, Expression&lt;Func&lt;TSource, TKey&gt;&gt; keySelector, Expression&lt;Func&lt;TKey, IEnumerable&lt;TSource&gt;, TResult&gt;&gt; resultSelector)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GroupBy(Of TSource, TKey, TResult)(source As IIndexedSource(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), resultSelector As Expression(Of Func(Of TKey, IEnumerable(Of TSource), TResult))) As IIndexedSource(Of TResult)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;TSource&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>An <a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource&lt;T&gt;</a> whose elements to group</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;TSource, TKey&gt;&gt;</td>
      <td><span class="parametername">keySelector</span></td>
      <td><p>A function to extract the key for each element.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-3">Func</a>&lt;TKey, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;TSource&gt;, TResult&gt;&gt;</td>
      <td><span class="parametername">resultSelector</span></td>
      <td><p>A function to create a result value from each group.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;TResult&gt;</td>
      <td><p>A collection of elements of type <i>TResult</i> where each element represents a projection over a group and its key.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">TSource</span></td>
      <td><p>The type of the elements of <i>source</i>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TKey</span></td>
      <td><p>The type of the key returned by <i>keySelector</i>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TResult</span></td>
      <td><p>The type of the result value returned by <i>resultSelector</i></p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_LiveLinq_IndexedQueryExtensions_GroupBy_" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy*"></a>
<h4 id="C1_LiveLinq_IndexedQueryExtensions_GroupBy__2_C1_LiveLinq_Indexing_IIndexedSource___0__System_Linq_Expressions_Expression_System_Func___0___1___" data-uid="C1.LiveLinq.IndexedQueryExtensions.GroupBy``2(C1.LiveLinq.Indexing.IIndexedSource{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}})">GroupBy&lt;TSource, TKey&gt;(IIndexedSource&lt;TSource&gt;, Expression&lt;Func&lt;TSource, TKey&gt;&gt;)</h4>
<div class="markdown level1 summary"><p>Groups the elements of a collection according to a specified key selector function.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static IIndexedSource&lt;IGrouping&lt;TKey, TSource&gt;&gt; GroupBy&lt;TSource, TKey&gt;(this IIndexedSource&lt;TSource&gt; source, Expression&lt;Func&lt;TSource, TKey&gt;&gt; keySelector)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GroupBy(Of TSource, TKey)(source As IIndexedSource(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey))) As IIndexedSource(Of IGrouping(Of TKey, TSource))</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;TSource&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>An <a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource&lt;T&gt;</a> whose elements to group</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;TSource, TKey&gt;&gt;</td>
      <td><span class="parametername">keySelector</span></td>
      <td><p>A function to extract the key for each element.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Indexing.IIndexedSource-1.html">IIndexedSource</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping</a>&lt;TKey, TSource&gt;&gt;</td>
      <td><p>A collection of <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.igrouping-2">IGrouping&lt;TKey, TElement&gt;</a> objects each containing a sequence of objects and a key.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">TSource</span></td>
      <td><p>The type of the elements of <i>source</i>.</p>
</td>
    </tr>
    <tr>
      <td><span class="parametername">TKey</span></td>
      <td><p>The type of the key returned by <i>keySelector</i>.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
