【发布时间】:2015-10-12 23:43:34
【问题描述】:
我在视图中使用 PagedList,但我的脚手架控制器是使用这种默认索引操作生成的:
public async Task<ActionResult> Index()
{
return View(await db.Claimants.ToListAsync());
}
我没有找到与 async 一起使用的 PagedList 扩展。我的方法必须改成这样的形式:
public ActionResult Index(int? page)
{
var claimants = db.Claimants.OrderBy(b => b.Name);
var notNullPage = page ?? 1;
return View(claimants.ToPagedList(notNullPage, 50));
}
是否有合理的方式来处理 PagedList 和 async?
【问题讨论】:
标签: c# asp.net-mvc async-await task-parallel-library pagedlist