Hi,
I am using the nice s#arp repositories and the paging extension method plus sorting like this:
public ViewResult Index(int? page, GridSortOptions sort)
{
ViewData["sort"] = sort;
if (!string.IsNullOrEmpty(sort.Column))
{
return View(this.LabService.GetAllLabs().OrderBy(sort.Column, sort.Direction).AsPagination(page ?? 1, 10));
}
...
My first question is:
(1) Is it correct that the sorting has to be done before the paging and that all this uses lazy loading (i.e. internally uses TOP n or something in the actual SQL)?
One of the short comings of the current mvc contrib grid implementation is that it does not allow sorting for customised columns (e.g. combined column values) like this:
String.Format("{0} {1}", lab.Proposer.LastName, lab.Proposer.FirstName)
(used in the view)
I tried to avoid view models in my fairly simple s#arp solution but perhaps I could do with a view model in this case to allow the sorting by custom columns.
I have used automapper to map domain models to view models and vice versa in the past. However, I have one issue with this solution. Does this still work using lazy loading?
In other words does automapper not have to map ALL domain objects to the view objects first before it can do sorting and paging resulting in decreased performance?
I hope this makes sense and you understand what I am getting at. Thanks.
Best wishes,
Christian