title: Using a PagedList with a ViewModel ASP.Net MVC
body: <p>I'm trying to using a PagedList in my ASP.Net application and I found this example on the Microsoft website <a href="http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application">http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application</a></p>
  
  <p>How is it possible to use a PagedList in a complex situation that uses a ViewModel? I'm trying to add a PagedList without success to the Instructor example posted here: <a href="http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application">http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</a></p>
  
  <p>The problem is that the ViewModel is composed by classes and not simple fields, so I cannot convert the result with the ToPageList() method.</p>
  
  <p>This is the ViewModel structure:</p>
  
  <pre><code>using System.Collections.Generic;
  using ContosoUniversity.Models;
  
  namespace ContosoUniversity.ViewModels
  {
      public class InstructorIndexData
      {
          public IEnumerable&lt;Instructor&gt; Instructors { get; set; }
          public IEnumerable&lt;Course&gt; Courses { get; set; }
          public IEnumerable&lt;Enrollment&gt; Enrollments { get; set; }
      }
  }
  </code></pre>
  
  <p>I need to join the three tables into the ViewModel and display the result in a View.</p>