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 hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
- ImportError: cannot import name 'url' from 'django.conf.urls' - Django Error
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
- ModuleNotFoundError: No module named 'openpyxl' - Python
- How to get thumbnail from vimeo video URL in Python?
Related Article