Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 2
|
BOOK: Professional ASP.NET MVC 2
This is the forum to discuss the Wrox book Professional ASP.NET MVC 2 by Jon Galloway, Scott Hanselman, Phil Haack, Scott Guthrie, Rob Conery; ISBN: Professional ASP.NET MVC 2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2010, 06:02 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help on skip() and take() Operator

While applying paging Author used skip() and take() Operator. Here I understand why he chose Skip(10) because we want to show 10 results per page but i dont understand why he used Take(20)? Why only 20?
 
Old October 12th, 2010, 12:22 PM
Friend of Wrox
 
Join Date: Oct 2010
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

That's got to be a typo. Later (Pg 106), pagination is refactored anyway and you see
.Take(PageSize)

PaginatedList.cs
Code:
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize)
{
	PageIndex = pageIndex;
	PageSize = pageSize;
	TotalCount = source.Count();
	TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize);
	this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
}

Last edited by flyinhawaiian; October 12th, 2010 at 12:24 PM.. Reason: Added page number





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to skip errors absu ADO.NET 1 October 6th, 2008 09:56 AM
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 04:51 AM
skip first field gilgalbiblewheel Classic ASP Databases 1 July 7th, 2007 05:10 PM
Why would this skip record #1? dep XSLT 8 November 1st, 2006 02:57 PM
Skip On Refresh Prabhakar_dt Classic ASP Basics 9 September 2nd, 2004 11:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.