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 enable Search Feature in Django admin?
- How to check PAN-Aadhaar is Linked or NOT?
- How to customize pagination for django admin?
- How to fix HAXM is not installed |in Android Studio
- How to fix CMOS Checksum Error in Computer or Laptop | SOLVED
- Reactivating windows after a Hardware change on PC or Laptop
- FIXED: Windows reported that the hardware of your device has changed. Error code :0xc004F211
- "redirect" is not defined pylance("reportUndefinedVariable)
Related Article