title: Why shouldn't use Linq in View
body: <p>Somewhere I had to use a linq statement for select a result set from my Model that Controller returned in Index ActionResult.
  for doing this, I googled "how to use linq in view razor" and I get the result and my application worked properly, but I see some recommendation that say "Don't use Linq in view".
  Why we shouldn't use it however it's possible?
  And if I don't want using it what's the solution?</p>
  
  <p>This is my query :</p>
  
  <pre><code> @using System.Linq
   @{var lst = (from x in item.Showtimes select x.ShowtimeDate).Distinct();}
   @foreach (var showTimeItem in lst)
      {
        &lt;option value="@showTimeItem"&gt;@showTimeItem&lt;/option&gt;   
      }
  </code></pre>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>This is my controller Index </p>
  
  <pre><code>public ActionResult Index()
          {
              MelliConcert.Models.MelliConcertEntities db = new  Models.MelliConcertEntities();
              var listOfConcerts = (from x in db.Concert
                                    orderby x.ID ascending
                                    select x).Take(15).ToList();
              return View(listOfConcerts);
          }
  </code></pre>
  
  <p>And i use it in the view like this :</p>
  
  <pre><code>@model IEnumerable&lt;MelliConcert.Models.Concert&gt;
   @foreach (var item in Model)
              {
                 @if (item.OpenedForFirst == true)
                 { 
                     //... 
                 }
                 //Some Codes
                 @using System.Linq
                 @{var lst = (from x in item.Showtimes select x.ShowtimeDate).Distinct();}
                 @foreach (var showTimeItem in lst)
                 {
                   &lt;option value="@showTimeItem"&gt;@showTimeItem&lt;/option&gt;   
                 }
              }
  </code></pre>
  
  <p>My linq statement placed in this loop.
  What should i do?</p>