public static List ReadUsersNotVisitorByPaging(int currentPage, int pagesize, out int totalPages, out int totalItems) {
List fullList = (from usr in ReadUsers().ToList()
where usr.Removed == false
orderby usr.Name
select usr).ToList();
totalItems = fullList.Count;
if (totalItems < pagesize)
totalPages = 1;
else
if ((fullList.Count % pagesize) == 0)
totalPages = fullList.Count / pagesize;
else
totalPages = (fullList.Count / pagesize) + 1;
//calcular o numero de items para fazer skip
int nextpage = 0;
if ((currentPage - 1) != 0)
nextpage = pagesize * (currentPage - 1);
List filterList = (from p in fullList.Skip(nextpage).Take(pagesize) select p).ToList();
Return filterList;
}
This return a list filter by size, is usefull for paging.
0 comentários:
Enviar um comentário