使用分页获取System.Collections.Generic.List不包含错误定义

时间:2015-09-21 17:38:20

标签: c# asp.net-mvc controller pagination

我有一个项目,我需要添加分页,但加载时我一直收到错误。我在MSDN网站上找到了此链接http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application。我正在通过它将此代码放在我的控制器中:

[HttpGet]
public ActionResult TechOpenTickets(int? page)
{

      ViewBag.Title = "Open Tickets Assigned To Me";

      var model = FindTechTickets(new Guid(Properties.Settings.Default.ActiveID));

      int pageSize = 3;
      int pageNumber = (page ?? 1);
      return View("TechOpen", model.ToPagedList(pageNumber, pageSize));

}

private IEnumerable<Ticket> FindTechTickets(Guid ticketStatusId)
{
      Guid g = Guid.Parse(Session["LoggedUserID"] as string);

      return db.Tickets
           .Include(t => t.TicketNotes)
           .Where(t => t.TechnicianId == g).Where(t => t.TicketStatusId == ticketStatusId)
           .OrderBy(t => t.OpenDate)
           .ToList();

}

然后在我看来,我在顶部有这个:

@model PagedList.IPagedList<HelpDesk.Model.Ticket>
@using PagedList;

我在返回视图时收到以下错误...&#39;在我的控制器中排队。

  

&#39; System.Collections.Generic.List<HelpDesk.Model.Ticket>&#39;才不是   包含&#39; ToPagedList&#39;

的定义

我错过了什么?

0 个答案:

没有答案