title: how to pass custom query results to view in asp.net
body: <p>i wants to pass the data from my controller to view.
  here is code of controller</p>
  
  <pre><code>public ActionResult AllCars()
      {
          try
          {
              int id = System.Web.HttpContext.Current.User.Identity.GetUserId&lt;int&gt;();
  
  
              var reservedCars = (from c in db.Cars
  
                              join o in db.Orders on c.Car_Id equals o.Car_Id
                              join u in db.AspNetUsers on o.Id equals u.Id
                              where u.Id == 5
                              select new
                              {
                                  c.Car_Description,
                                  c.Car_Id,
                                  c.CarMakeId,
                                  c.CarModelId,
                                  c.Reservation_Status,
                                  c.Color
                              });
  
          return View(reservedCars);
      }
      catch (Exception)
      {
  
          throw;
      }
  }
  </code></pre>
  
  <p>here is my view file.</p>
  
  <pre><code>@model IEnumerable&lt;FinalProject.Models.ReservedCar&gt;
  
  
  
  &lt;table&gt;
      @foreach (var item in Model)
      {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Car_Id);
              &lt;/td&gt;
          &lt;/tr&gt;
       }
      &lt;/table&gt;
  </code></pre>
  
  <p><strong>but when i run my view i got following error 
  The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery but this dictionary requires a model item of type 'System.Collections.IEnumerable`</strong></p>
  
  <p>i know im passing dbquery result to view and my view is expecting it will be iEnumerable.
  Please guide me how i can achieve thhis task.? i just wants to pass query results into my view and wants to use it.</p>
  
  <p>ModelClass.
  ReservedCar.cs</p>
  
  <pre><code>namespace FinalProject.Models
  {
      using System;
      using System.Collections.Generic;
      using System.ComponentModel.DataAnnotations;
      using System.ComponentModel.DataAnnotations.Schema;
      using System.Data.Entity.Spatial;
  
      public partial class ReservedCar
      {
  
          public int Id { get; set; }
  
          public string Car_Description { get; set; }
  
          public int Car_Id { get; set; }
  
          public string CarMakeId { get; set; }
  
          public string CarModelId { get; set; }
          public string Reservation_Status { get; set; }
  
          public string Color { get; set; }
      }
  }
  </code></pre>