# C1.LiveLinq.LiveViews.View-1.GroupBy

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_LiveLinq_LiveViews_View_1_GroupBy_" data-uid="C1.LiveLinq.LiveViews.View`1.GroupBy*">GroupBy Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_LiveLinq_LiveViews_View_1_GroupBy_" data-uid="C1.LiveLinq.LiveViews.View`1.GroupBy*"></a>
<h4 id="C1_LiveLinq_LiveViews_View_1_GroupBy__1_System_Linq_Expressions_Expression_System_Func__0___0___" data-uid="C1.LiveLinq.LiveViews.View`1.GroupBy``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">GroupBy&lt;TKey&gt;(Expression&lt;Func&lt;T, TKey&gt;&gt;)</h4>
<div class="markdown level1 summary"><p>Groups the elements of a view 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 View&lt;GroupView&lt;TKey, T&gt;&gt; GroupBy&lt;TKey&gt;(Expression&lt;Func&lt;T, TKey&gt;&gt; keySelector)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function GroupBy(Of TKey)(keySelector As Expression(Of Func(Of T, TKey))) As View(Of GroupView(Of TKey, T))</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="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;T, 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.LiveViews.View-1.html">View</a>&lt;<a class="xref" href="C1.LiveLinq.LiveViews.GroupView-2.html">GroupView</a>&lt;TKey, T&gt;&gt;</td>
      <td><p>A view containing elements of type <a class="xref" href="C1.LiveLinq.LiveViews.GroupView-2.html">GroupView&lt;TKey, TElement&gt;</a> each containing a key value
and a view of the elements having that key value.</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">TKey</span></td>
      <td><p>The type of the key returned by <i>keySelector</i>.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_LiveLinq_LiveViews_View_1_GroupBy_" data-uid="C1.LiveLinq.LiveViews.View`1.GroupBy*"></a>
<h4 id="C1_LiveLinq_LiveViews_View_1_GroupBy__2_System_Linq_Expressions_Expression_System_Func__0___0___System_Linq_Expressions_Expression_System_Func__0___1___" data-uid="C1.LiveLinq.LiveViews.View`1.GroupBy``2(System.Linq.Expressions.Expression{System.Func{`0,``0}},System.Linq.Expressions.Expression{System.Func{`0,``1}})">GroupBy&lt;TKey, TElement&gt;(Expression&lt;Func&lt;T, TKey&gt;&gt;, Expression&lt;Func&lt;T, TElement&gt;&gt;)</h4>
<div class="markdown level1 summary"><p>Groups the elements of a view 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 View&lt;GroupView&lt;TKey, TElement&gt;&gt; GroupBy&lt;TKey, TElement&gt;(Expression&lt;Func&lt;T, TKey&gt;&gt; keySelector, Expression&lt;Func&lt;T, TElement&gt;&gt; elementSelector)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function GroupBy(Of TKey, TElement)(keySelector As Expression(Of Func(Of T, TKey)), elementSelector As Expression(Of Func(Of T, TElement))) As View(Of GroupView(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="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;T, 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;T, TElement&gt;&gt;</td>
      <td><span class="parametername">elementSelector</span></td>
      <td><p>A function to map each source element to a <i>TElement</i>.</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.LiveViews.View-1.html">View</a>&lt;<a class="xref" href="C1.LiveLinq.LiveViews.GroupView-2.html">GroupView</a>&lt;TKey, TElement&gt;&gt;</td>
      <td><p>A view containing elements of type <a class="xref" href="C1.LiveLinq.LiveViews.GroupView-2.html">GroupView&lt;TKey, TElement&gt;</a> each containing a key value
and a view of the elements projected (mapped) from the elements having that key value.</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">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 element to which elements of each group are projected.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_LiveLinq_LiveViews_View_1_GroupBy_" data-uid="C1.LiveLinq.LiveViews.View`1.GroupBy*"></a>
<h4 id="C1_LiveLinq_LiveViews_View_1_GroupBy__3_System_Linq_Expressions_Expression_System_Func__0___0___System_Linq_Expressions_Expression_System_Func__0___1___System_Linq_Expressions_Expression_System_Func___0_System_Collections_Generic_IEnumerable___1____2___" data-uid="C1.LiveLinq.LiveViews.View`1.GroupBy``3(System.Linq.Expressions.Expression{System.Func{`0,``0}},System.Linq.Expressions.Expression{System.Func{`0,``1}},System.Linq.Expressions.Expression{System.Func{``0,System.Collections.Generic.IEnumerable{``1},``2}})">GroupBy&lt;TKey, TElement, TResult&gt;(Expression&lt;Func&lt;T, TKey&gt;&gt;, Expression&lt;Func&lt;T, 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 view 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 View&lt;TResult&gt; GroupBy&lt;TKey, TElement, TResult&gt;(Expression&lt;Func&lt;T, TKey&gt;&gt; keySelector, Expression&lt;Func&lt;T, 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 Function GroupBy(Of TKey, TElement, TResult)(keySelector As Expression(Of Func(Of T, TKey)), elementSelector As Expression(Of Func(Of T, TElement)), resultSelector As Expression(Of Func(Of TKey, IEnumerable(Of TElement), TResult))) As View(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="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;T, 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;T, 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.LiveViews.View-1.html">View</a>&lt;TResult&gt;</td>
      <td><p>A view 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">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 groups.</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>
</div>
