title: Paging on large amounts of data in MVC using custom logic
body: <p>I want to implement Paging, Searching, Sorting on large amount of data (DB has 2 - 3 million records) in MVC. While using default paging option in MVC (using <code>PagedList.Mvc</code>, <code>@Html.PagedListPager</code>)  all records are fetched for DB &amp; only 100 records are displayed on page. That's time consuming &amp; used more memory.</p>
  
  <p>How can I implement custom logic in MVC that only retrieves exact 100 records per page? Currently I am trying both approaches (using EF and SP).</p>
  
  <p>I have already developed sample applications using EF &amp; SP and implement default paging. But both approaches retrieves all records from DB &amp; then apply paging on client side. That's too time consuming.</p>
  
  <pre><code>public ActionResult Index(int? page) { 
        return View(db.TestUploadData2.ToList().ToPagedList(page ?? 1, 100));
   }
  </code></pre>
  
  <p>Any suggestions?</p>