本文介绍了如何从NuGet中的PagedList.Mvc页面进行翻页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从NuGet安装:Entity Framework和PagedList.Mvc

I have installed from NuGet: Entity Framework and PagedList.Mvc

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'.

推荐答案

return View(db.Data1.OrderBy(x => x.SomeProperty).ToPagedList(pageNumber, pageSize));





有关该问题的更多信息。



More information is in that issue.


这篇关于如何从NuGet中的PagedList.Mvc页面进行翻页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 11:48