Метод PagedListPager () не работает, в то время как все конфигурации в порядке - PullRequest
0 голосов
/ 29 октября 2018

У меня есть простой вид нумерации страниц следующим образом:

@using PagedList;
@using PagedList.Mvc;
@model PagedList.IPagedList<PgcbSms.Core.Entities.SmsLog>

@{
    ViewData["Title"] = "SMSLog";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>SMSLog</h2>

<table class="table table-striped">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.First().originator)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().content)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().messageDate)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().receivedDate)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().dbinsertdate)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().status)
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.originator)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.content)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.messageDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.receivedDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.dbinsertdate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.status)
                </td>
            </tr>
        }
    </tbody>
</table>
@Html.PagedListPager(Model, page => Url.Action("SMSLog", new { page}))

Но я получаю следующую ошибку:

enter image description here

Я добавляю две строки:

@using PagedList;
@using PagedList.Mvc;

и изучите код нумерации страниц в asp.net mvc, но в моем коде ничего не пропущено. Так почему я получаю такую ​​ошибку? Любая идея? спасибо за ваше время.

UPDATE: Контроллер:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using PgcbSms.Core.Entities;
using PgcbSms.Services.SmsLogServices;
using PagedList;
using PagedList.Mvc;

namespace PgcgSms.WebSite.Controllers
{
    public class ReportsController : Controller
    {
        private ISmsLogService _smsLogService;
        public ReportsController(ISmsLogService smsLogService)
        {
            _smsLogService = smsLogService;
        }
        public IActionResult SMSLog(int? page)
        {
            IPagedList<SmsLog> smsLogs = _smsLogService.GetSmsLogsPaged(page);
            return View(smsLogs);
        }
    }
}

Update2:

 public IPagedList<SmsLog> GetSmsLogsPaged(int? page)
        {
            return _smsRepository.Table.ToList().ToPagedList(page ?? 1, 10);
        }
...