title: How Do I Use A Tuple Properly in ASP.NET MVC 4
body: <p>I'm trying to use two models in one view using a tuple but I'm getting this error:
  Server Error in '/' Application.</p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type 'PagedList.PagedList<code>1[S00117372CA3.Product]', but this dictionary requires a model item of type 'System.Tuple</code>2[PagedList.IPagedList<code>1[S00117372CA3.Product],System.Collections.Generic.IEnumerable</code>1[S00117372CA3.Order]]'.</p>
  </blockquote>
  
  <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
  
  <blockquote>
    <p>Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'PagedList.PagedList<code>1[S00117372CA3.Product]', but this dictionary requires a model item of type 'System.Tuple</code>2[PagedList.IPagedList<code>1[S00117372CA3.Product],System.Collections.Generic.IEnumerable</code>1[S00117372CA3.Order]]'.</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>    @*@model PagedList.IPagedList&lt;S00117372CA3.Product&gt;*@
  @model Tuple&lt;PagedList.IPagedList&lt;S00117372CA3.Product&gt;, IEnumerable&lt;S00117372CA3.Order&gt;&gt;
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].ProductName)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].Supplier.CompanyName)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].Category.CategoryName)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].QuantityPerUnit)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].UnitPrice)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].UnitsInStock)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].UnitsOnOrder)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].ReorderLevel)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Item1[0].Discontinued)
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  
  @foreach (var item in Model.Item1) {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.ProductName)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Supplier.CompanyName)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Category.CategoryName)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.QuantityPerUnit)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.UnitPrice)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.UnitsInStock)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.UnitsOnOrder)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.ReorderLevel)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Discontinued)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.ActionLink("Edit", "Edit", new { id=item.ProductID }) |
              @Html.ActionLink("Details", "Details", new { id=item.ProductID }) |
              @Html.ActionLink("Delete", "Delete", new { id=item.ProductID })
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  
  &lt;/table&gt;
  
  &lt;div&gt;
      Page @(Model.Item1.PageCount &lt; Model.Item1.PageNumber ? 0 : Model.Item1.PageNumber) of @Model.Item1.PageCount
      @if (Model.Item1.HasPreviousPage)
      {
          @Html.ActionLink("&lt;&lt;", "Index", new { page = 1})
          @Html.Raw(" ");
          @Html.ActionLink("&lt; Prev", "Index", new {page = Model.Item1.PageNumber - 1})
      }
      else{
       @:&lt;&lt;
       @Html.Raw(" ");
          @:&lt; Prev   
      }
  
      @if (Model.Item1.HasNextPage)
      {
          @Html.ActionLink("Next &gt;", "Index", new {page = Model.Item1.PageNumber + 1})
          @Html.Raw(" "); 
          @Html.ActionLink("&gt;&gt;", "Index", new {page = Model.Item1.PageCount})
      }
      else{
       @:Next &gt;
       @Html.Raw(" ")
  @:&gt;&gt;   
      }
  &lt;/div&gt;
  
  @foreach (var item in Model.Item2)
  {
      @Html.Partial("_Orders")
  }
  </code></pre>
  
  <p>Here is my controller code as requested:</p>
  
  <pre><code>var q = (from o in db.Order_Details
                       where o.ProductID == id
                       join ord in db.Orders
                       on o.OrderID equals ord.OrderID
                       orderby o.Quantity descending
                       select ord);
              var qm = q.Take(3);
              return PartialView("_Orders", qm.ToList());
  </code></pre>