Asp.Net Core 使用X.PagedList.Mvc.Core分页
1.Nuget包添加引用: X.PagedList.Mvc.Core
2.View:
@model X.PagedList.IPagedList<CodeFirstCore.Models.Users>
@using X.PagedList.Mvc.Core;
----------------------------------------------------------------------------------------
@foreach (var item in Model)
{
<tr>
<td>@item.Id</td>
<td>@item.Name</td>
</tr>
}
@Html.PagedListPager(Model, page => Url.Action("UserList", new { page }))
3.Controller
using X.PagedList;
public ActionResult DeviceList(int page = 1, int pagesize = 15)
{
var query = db.Device.ToList();
return View(query.ToPagedList(page, pagesize));
}