如何从NuGet中的PagedList.Mvc页面进行翻页? [英] How do I page from PagedList.Mvc in NuGet?

查看:73
本文介绍了如何从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'.

推荐答案

此问题已在项目的GitHub页面上报告: https://github.com/troygoode/PagedList/issues/92 [ ^ ]。



基本上,您必须将代码更新为:

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:
return View(db.Data1.OrderBy(x => x.SomeProperty).ToPagedList(pageNumber, pageSize));





有关该问题的更多信息。



More information is in that issue.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆