这是我的存储库层:
public List<Section> GetAllSections()
{
return context.Sections.Include("Groups").Include("Groups.Classes").ToList();
}这是我的应用层:
public List<Section> GetAllSections()
{
return cacheSectionRepo.GetAllSections();
}在控制器中,我有:
SectionApplication sectionApp = new SectionApplication();
public ActionResult Index()
{
return View(sectionApp.GetAllSections());
}现在,我想让我的Index视图成为页面。我想从PagedList.How使用,我应该这样做吗?例如,我希望每页显示5条记录。
发布于 2013-04-09 17:43:08
您可以将页码和页面大小传递给存储库层,然后使用Skip和Take Linq语句过滤出所需的行:
public List<Section> GetAllSections(int pageSize=5, int pageNo)
{
return cacheSectionRepo.GetAllSections().Skip(pageSize * pageNo).Take(pageSize);;
}或者,您可以在您的存储库层中执行该过滤。然后,对于每个对控制器的请求,您将把pageNo发送到控制器,最好是通过AJAX请求。
https://stackoverflow.com/questions/15898429
复制相似问题