Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have installed from NuGet: Entity Framework and PagedList.Mvc
C#
using PagedList;

namespace FilteringPagingSorting.Controllers
{
    public class HomeController : Controller
    {
        private testContext db = new testContext();
        public ActionResult Index(int? page)
        {
            int pageSize = 3;
            int pageNumber = (page ?? 1);
            return View(db.Data1.ToPagedList(pageNumber, pageSize));
        }
    }
}

Error code:
An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code

Additional information: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
Posted

1 solution

This issue has been reported on the project's GitHub page here: https://github.com/troygoode/PagedList/issues/92[^].

Essentially, you will have to update your code to:
C#
return View(db.Data1.OrderBy(x => x.SomeProperty).ToPagedList(pageNumber, pageSize));


More information is in that issue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900