PagedList with large data sets I'm using X.PagedList for paging functionality in my application.  The code I have works fine but when I return larger sets of data it seems like it could be faster.  Is there anything I can do to my code to have it perform more efficiently?

Controller Code

var employees = _service.GetEmployeesByOffice(region, area, office).OrderBy(e =&gt; e.FullName);
var model = Mapper.Map&lt;IEnumerable&lt;Employee&gt;,IEnumerable&lt;EmployeesViewModel&gt;&gt;(employees).ToPagedList(page, 20);

var viewModel = new EmployeeListingView
{
    EmployeeViewModel = model,
    // Additional...
};

return View(viewModel);


Service Call

public IEnumerable&lt;Employee&gt; GetEmployeesByOffice(string region, string area, string office)
{
    var query = _context.Employees.AsQueryable();

    if (!String.IsNullOrEmpty(region))
        query = query.Where(e =&gt; e.Region == region);

    if (!String.IsNullOrEmpty(area))
        query = query.Where(e =&gt; e.Area == area);

    if (!String.IsNullOrEmpty(office))
        query = query.Where(e =&gt; e.Office == office);

    return query;
}


Razor Page

@Html.PagedListPager((IPagedList)Model.EmployeeViewModel, page =&gt; Url.Action("Index", new { area = Model.SelectedArea, office = Model.SelectedOffice, page }))
So it seems that the issue was with the mapping.  Using this answer, I created an extension to handle mapping the object after calling it.  I changed this code


var employees = 
      _service
          .GetEmployeesByOffice(region, area, office)
          .OrderBy(e =&gt; e.FullName);
var model = 
      Mapper.Map&lt;IEnumerable&lt;Employee&gt;, IEnumerable&lt;EmployeesViewModel&gt;&gt;(employees)
      .ToPagedList(page, 20);



to this

var model = 
    _service
        .GetEmployeesByOffice(region, sArea, sOffice)
        .OrderBy(e =&gt; e.FullName)
        .ToPagedList(page, 20)
        .ToMappedPagedList&lt;Employee, EmployeesViewModel&gt;();