I'm using PagedList in my Views, but my scaffolded Controller is generated with this kind of default Index Action:
public async Task<ActionResult> Index()
{
return View(await db.Claimants.ToListAsync());
}
I didn't find an extension for PagedList to work with async
. My methods have to be changed to a form like this:
public ActionResult Index(int? page)
{
var claimants = db.Claimants.OrderBy(b => b.Name);
var notNullPage = page ?? 1;
return View(claimants.ToPagedList(notNullPage, 50));
}
Is there a reasonable way to work with PagedList and async
?
Yes, you can.
You can use X.PagedList which is an improved version of PagedList and supports async operations.
Yes. Doesn't come out of the box with EF. But, you can get
PagedList.EntityFramework
which exposes aToPagedListAsync
: