title: Cannot implicitly convert type 'System.Collections.Generic.List to 'System.Collections.Generic.IEnumerable error in asp.net mvc
body: <p>I got the error from my below code</p>
  
  <blockquote>
    <p>Error  CS0266  Cannot implicitly convert type 'System.Collections.Generic.List to 'System.Collections.Generic.IEnumerable&lt;Theme_Hisaab.Models.CustomerLedger>'. An explicit conversion exists (are you missing a cast?) </p>
  </blockquote>
  
  <p>Controller Code</p>
  
  <pre><code>public class CustomerLedgerController : Controller
  {
      // GET: CustomerLedger
      Hisaab_ApplicationEntities7 db = new Hisaab_ApplicationEntities7();
  
      IEnumerable&lt;CustomerLedger&gt; CustomerLedger = null;
      public ActionResult Index()
      {
  
          CustomerLedger = (from cus_data in db.Customer_Data
                            join so in db.SalesOrder on cus_data.Customer_ID equals so.SalesOrder_ID
                            join sd in db.SalesOrderDetail on so.SalesOrder_ID equals sd.SalesOrderDetail_ID
                            select new
                            {
                                cus_data.Customer_Name,
                                cus_data.Customer_ID,
                                so.SalesOrder_ID,
                                so.FK_Customer_ID,
                                sd.SalesOrderDetail_ID,
                                sd.SalesOrder_Unit_Price,
                                sd.SalesOrder_Total,
                                sd.FK_SalesOrder_ID,
                                sd.FK_Product_ID
                            }
                             ).ToList();
          return View(CustomerLedger);
      }
  }
  </code></pre>
  
  <p>ViewModel</p>
  
  <pre><code>public class CustomerLedger
  {
      public int Customer_ID { get; set; }
      public string Customer_Name { get; set; }
      public int SalesOrder_ID { get; set; }
      public Nullable&lt;int&gt; FK_Customer_ID { get; set; }
      public Nullable&lt;System.DateTime&gt; SalesOrderDelivery_Date { get; set; }
      public string Product_Name { get; set; }
      public Nullable&lt;int&gt; SalesOrder_Quantity { get; set; }
      public Nullable&lt;double&gt; SalesOrder_Unit_Price { get; set; }
      public Nullable&lt;double&gt; SalesOrder_Total { get; set; }
      public int SalesOrderDetail_ID { get; set; }
      public Nullable&lt;int&gt; FK_SalesOrder_ID { get; set; }
      public Nullable&lt;int&gt; FK_Product_ID { get; set; }
  
      public Customer_Data Customer_Data { get; set; }
      public SalesOrderDetail SalesOrderDetail { get; set; }
      public SalesOrder SalesOrder { get; set; }
  }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>@model IEnumerable&lt;Theme_Hisaab.Models.CustomerLedger&gt;
  ....
   &lt;table class="table"&gt;
   &lt;tr&gt;
       &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.Customer_ID)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.Customer_Name)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.SalesOrder_ID)
      &lt;/th&gt;
      ....
      &lt;th&gt;&lt;/th&gt;
  &lt;/tr&gt;
  
  @foreach (var item in Model) {
  &lt;tr&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.Customer_ID)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.Customer_Name)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.SalesOrder_ID)
      &lt;/td&gt;
      ....
      &lt;td&gt;
          @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
          @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey      */ }) |
          @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
      &lt;/td&gt;
  &lt;/tr&gt;
  }
  &lt;/table&gt;
  </code></pre>