This is the default action from the "View" of my MVC4 application.
public ActionResult Index(string sort = "R_ResDate",
string sortdir = "DESC",
int page = 1)
{
List<Result> results = modRes.Results.ToList();
var results = from r in results
orderby r.R_ResultDate descending
select r;
return View(results);
}
Where modRes
is a Model class,
I wanted to use the sort column, sortDir, and page arguments in the dynamic linq to derive the results.
Any help would be appreciated.
You can use this code for paging and sorting data:
Also, you shouldn't to call
ToList
method onmodRes.Results
query, because in this case will be loaded all data, when only data for one page should be loaded.