# C1.LiveLinq.LiveViewExtensions.LiveCount

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_LiveLinq_LiveViewExtensions_LiveCount_" data-uid="C1.LiveLinq.LiveViewExtensions.LiveCount*">LiveCount Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_LiveLinq_LiveViewExtensions_LiveCount_" data-uid="C1.LiveLinq.LiveViewExtensions.LiveCount*"></a>
<h4 id="C1_LiveLinq_LiveViewExtensions_LiveCount__1_C1_LiveLinq_LiveViews_View___0__" data-uid="C1.LiveLinq.LiveViewExtensions.LiveCount``1(C1.LiveLinq.LiveViews.View{``0})">LiveCount&lt;T&gt;(View&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>A view representing the number of elements in a view.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static AggregationView&lt;T, int&gt; LiveCount&lt;T&gt;(this View&lt;T&gt; source)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function LiveCount(Of T)(source As View(Of T)) As AggregationView(Of T, Integer)</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.LiveViews.View-1.html">View</a>&lt;T&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>A view that contains elements to be counted.</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.AggregationView-2.html">AggregationView</a>&lt;T, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>&gt;</td>
      <td></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">T</span></td>
      <td><p>The type of the elements of <i>source</i>.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_LiveLinq_LiveViewExtensions_LiveCount__1_C1_LiveLinq_LiveViews_View___0___remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>It is possible to use standard LINQ query operator <b>Count</b> instead of <b>LiveCount</b>.
Both are &quot;live&quot; in the sense that they are recomputed automatically when any change occurs in the source.
The difference is that <b>Count</b> will every time loop through the entire source collection and aggregate it from scratch,
whereas <b>LiveCount</b> will use a more performant algorithm, will maintain its value incrementally,
processing only those source items that actually changed.</p>
</div>


<a id="C1_LiveLinq_LiveViewExtensions_LiveCount_" data-uid="C1.LiveLinq.LiveViewExtensions.LiveCount*"></a>
<h4 id="C1_LiveLinq_LiveViewExtensions_LiveCount__1_C1_LiveLinq_LiveViews_View___0__System_Linq_Expressions_Expression_System_Func___0_System_Boolean___" data-uid="C1.LiveLinq.LiveViewExtensions.LiveCount``1(C1.LiveLinq.LiveViews.View{``0},System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">LiveCount&lt;T&gt;(View&lt;T&gt;, Expression&lt;Func&lt;T, bool&gt;&gt;)</h4>
<div class="markdown level1 summary"><p>A view representing the number of elements of the specified view satisfying a condition.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static AggregationView&lt;T, int&gt; LiveCount&lt;T&gt;(this View&lt;T&gt; source, Expression&lt;Func&lt;T, bool&gt;&gt; predicate)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function LiveCount(Of T)(source As View(Of T), predicate As Expression(Of Func(Of T, Boolean))) As AggregationView(Of T, Integer)</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.LiveViews.View-1.html">View</a>&lt;T&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>A view that contains elements to be tested and counted.</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, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a>&gt;&gt;</td>
      <td><span class="parametername">predicate</span></td>
      <td><p>A function to test each element for a condition.</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.AggregationView-2.html">AggregationView</a>&lt;T, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>&gt;</td>
      <td></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">T</span></td>
      <td><p>The type of the elements of <i>source</i>.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_LiveLinq_LiveViewExtensions_LiveCount__1_C1_LiveLinq_LiveViews_View___0__System_Linq_Expressions_Expression_System_Func___0_System_Boolean____remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>It is possible to use standard LINQ query operator <b>Count</b> instead of <b>LiveCount</b>.
Both are &quot;live&quot; in the sense that they are recomputed automatically when any change occurs in the source.
The difference is that <b>Count</b> will every time loop through the entire source collection and aggregate it from scratch,
whereas <b>LiveCount</b> will use a more performant algorithm, will maintain its value incrementally,
processing only those source items that actually changed.</p>
</div>
</div>
