PagedList 1.0

 Recommended Download



Source Code PagedList 1.0 Source.zip
source code, 166K, uploaded Jun 11 2009  - 279 downloads

 Other Available Downloads



Application PagedList 1.0 Binaries.zip
application, 7K, uploaded Jun 12 2009  - 128 downloads

Release Notes

Project Description

PagedList makes it easier for .Net developers to write paging code. It allows you to take any List<T> and by specifying the page size and desired page index, select only a subset of that list. PagedList also provides properties that are useful when building UI paging controls.

Using PagedList<T>

using System;
using System.Collections.Generic;
using PagedList;

public class Program
{
	public static void Main(string[] args)
	{
		// create a list of integers from 1 to 200
		var list = new List<int>();
		for(var i = 1; i <= 200; i++)
			list.Add(i);

		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();

		var anotherPage = list.ToPagedList(4, 20); // fifth page, page size = 20
		Console.WriteLine("Is first page? {0}", anotherPage.IsFirstPage); // false
		Console.WriteLine("Is last page? {0}", anotherPage.IsLastPage); // false
		Console.WriteLine("Total integers in list? {0}", anotherPage.TotalItemCount); // 200
		Console.WriteLine("Integers on this page? {0}", anotherPage.Count); // 20
		Console.WriteLine("First value on page? {0}", anotherPage[0]); // 81
		Console.WriteLine();

		var lastPage = list.ToPagedList(9, 20); // last (tenth) page, page size = 20
		Console.WriteLine("Is first page? {0}", lastPage.IsFirstPage); // false
		Console.WriteLine("Is last page? {0}", lastPage.IsLastPage); // true
		Console.WriteLine("First value on page? {0}", lastPage[0]); // 181
		Console.ReadKey(false);
	}
}

Changes

  • June 11, 2009 Troy Goode posts further tweaks to PagedList<T> code, adds Intellisense documentation, adds source to CodePlex, and creates a signed release binary available for download via CodePlex.
    • Eliminated extraneous call to .Skip(n) when n == 0. Reported by Craig Stuntz.
    • Removed constructor overload to PagedList<T> that accepted IQueryable<T>.
    • Removed protected Initialize method and moved code into only remaining constructor.
    • Optimized constructor to work for IEnumerable<T> or IQueryable<T>.
    • Moved property calculations for PageNumber, HasPreviousPage, HasNextPage, IsFirstPage, and IsLastPage from constructor to property getter. Given that these properties are not likely called in loops, the potential performance hit is likely made up for by the enhanced readability of the constructor code.
    • Removed overload of ToPagedList extension method that took IQueryable<T>.
    • Renamed Pagination static extensions methods class to PagedListExtensions.
    • Added test to verify that when there are two pages of 1 item each, the second page will contain the correct item (the test passed). Suggested by Matt Bertulli.
    • Moved code from System.Collections.Generics namespace to PagedList.
    • Created a solution just for PagedList related classes and signed the assembly using a private key generated just for PagedList.
    • Added XML documentation for all interfaces, classes, methods, and properties.
 Reviews for this release
No reviews yet for this release.
Updating...
© 2006-2010 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2010.1.12.16187