Will_paginate for ASP.NET MVC

I ran into the problem of swapping my list object in asp.net mvc, where my object just loads LINQ-to-SQL.

Are these several kinds of will_paginates command?

in rails, I can do as

Users.paginate(:all, :page => 1, :page_size => 20)
+1
source share
3 answers

Check out - http://pagedlist.codeplex.com/

The ToPagedList extension method will be created, which can be used as follows:

 using PagedList;

 var firstPage = list.ToPagedList(0, 20); // first page, page size = 20

 Console.WriteLine("Is first page? {0}", firstPage.IsFirstPage); // true
 Console.WriteLine("Is last page? {0}", firstPage.IsLastPage); // false
 Console.WriteLine("First value on page? {0}", firstPage[0]); // 1
 Console.WriteLine();
+4
source

In Linq, it will be

Users.Skip(pageSize*page).Take(pageSize)

This will count a count based on a zero value.

+4
source

All Articles