The method 'Skip' is only supported for sorted input in LINQ to Entities.
The method 'OrderBy' must be called before the method 'Skip'.
I got this above error while running the asp.net mvc application.I want to generate paging control for grid. So I had installed pagedList Library in the application. I used the following function,
public ActionResult Index(int? page)
{
int maxRows = 5;
int pageNumber = (page ?? 1);
return View(db.Staffs.ToPagedList(pageNumber, maxRows));
}
Solution:
You should convert IList or IEnumerable into IQueryable in asp.net MVC Application like below.
public ActionResult Index(int? page)
{
int maxRows = 5;
IQueryable<Staff> staffs = (from staff in db.Staffs
select staff)
.OrderBy(student =>student.StaffId);
int pageNumber = (page ?? 1);
return View(staffs.ToPagedList(pageNumber, maxRows)); }
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article