title: How to retrieve data for two different portions of a single web page using LINQ from the same database table?
body: <p>I am working on a project in <code>.NET MVC5</code> using code first approach, I have created a database table and I want to retrieve some specific records in two different portions (categories as of database) of Index page or (Home Page) from the same database table.</p>
  
  <p>I have created the below controller which works fine for one of the portions named "Recent Events" but I am puzzled when I try to retrieve some records for the second portion of home page, suppose which is named as "Featured_Events" using the same controller?</p>
  
  <p>Initially i just want the logic to work fine for the both portions,  but in case if an expert is reading my post, Then kindly also tell me how can i retrieve specific number of records in Featured Events portion, As you know that i am retrieving 8 records in Recent Events, what if i want to retrieve 12 records in Featured Events section?</p>
  
  <p>This is the controller:</p>
  
  <pre><code>public ActionResult Index()
  {
       var result = (from i in _context.consult
                     orderby i.date_of_event descending
                     where i.category == "recent_events"
                     select i).Take(8);
       return View(result);
   }
  </code></pre>
  
  <p>Just for further clarification: In the view I use <code>foreach</code> loop to retrieve data:
  As an example It looks like this:</p>
  
  <pre><code>@model Ienumurable &lt;Example.Models.consultation&gt;
  </code></pre>
  
  <p>CODE FOR RECENT EVENTS PORTION </p>
  
  <pre><code>@foreach (var recent in Model)
  {
      if (@recent.category == "recent_events")
      {
          &lt;p&gt;@recent.date&lt;/p&gt;
          &lt;p&gt;@recent.details&lt;/p&gt;
      }
  }
  </code></pre>
  
  <p>CODE FOR FEATURED EVENTS PORTION </p>
  
  <pre><code>@foreach (var featured in Model)
  {
      if (@featured.category == "featured_events")
      {
          &lt;p&gt;@featured.date&lt;/p&gt;
          &lt;p&gt;@featured.details&lt;/p&gt;
      }
  }
  </code></pre>
  
  <p>I would be really glad if anyone could assist me in this regard. </p>