Skip to main content
Home  › ... 2sxc Apps

LINQ Tutorials

Tutorial Home
  1. All Persons: 6
  2. All Books: 4
  3. Books with Illustrators: 1

<ol>
  <li>
    All Persons: @persons.Count()
  </li>
  <li>
    All Books: @books.Count()
  </li>
  <li>
    Books with Illustrators: @books.Where(b => (b.Illustrators as Dynlist).Count() > 0).Count()
  </li>
</ol>

Source Code of this file

Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code

@inherits Custom.Hybrid.Razor14
@using System.Linq;
@using Dynlist = System.Collections.Generic.IEnumerable<dynamic>;

<!-- unimportant stuff, hidden -->

@{
  var persons = AsList(App.Data["Persons"]);
  var books = AsList(App.Data["Books"]);
}

@Html.Partial("_header.cshtml")

<div class="row">
  <div class="col-lg-7">
    <h2>Count()</h2>
    <p>Count some stuff.</p>
  </div>
  @Html.Partial("../shared/_DefaultInfoSection.cshtml")

</div>


<ol>
  <li>
    All Persons: @persons.Count()
  </li>
  <li>
    All Books: @books.Count()
  </li>
  <li>
    Books with Illustrators: @books.Where(b => (b.Illustrators as Dynlist).Count() > 0).Count()
  </li>
</ol>



<!-- unimportant stuff, hidden -->