4
I would like to make the pagination, but using Skip
and Take
on my LINQ not to fetch all results.
Currently my code is like this:
public ViewResult Index(int? page)
{
var grupos= from s in db.grupos
select s;
int pageSize = 3;
int pageNumber = (page ?? 1);
return View(grupos.ToPagedList(pageNumber, pageSize));
}
As use Skip
and Take
on my LINQ?
Yes, but where do these values 10, 20 come from using the Helper?
– Rod
It’s any value I used as an example. Usually you calculate the values according to the current page. In Skip you can pass
(page - 1) * size
and in Take only the size; where page is the current page and size the amount of records presented.– Juliano Alves