Page - HendrickxJorn/Gobln.Pager GitHub Wiki

#Page

Page contains an list of object that represents of the current page data. You wont be able to add or remove items form Page, or Page. You can easly create an new Page from an Ienumable, IQueryable or PagedList.

For information of creating an Page form a PagedList, check here

To create an Page form an array, use the folling code. This will create the first page of 2 items from an array of strings


var page = new string[]
                {
                    "test1",
                    "test2",
                    "test3",
                    "test4",
                    "test5",
                    "test6",
                    "test7",
                    "test8"
                }.ToPage(1, 2);

If you woulden't give any values to the ToPage(), the default values will be used, page index = 1 and page size is the same al the array

It is also possible to use linq before creating an page.


//lets say listof100 is an collection of 100 items, containing name, street and creationdate field
var page = listof100
            .Where(c => c.CreationDate > new Date(2018, 01, 01) )
            .ToPage(2, 10);

This will create an page form the item 11 to 20 that are greater then 2018-01-01.

You are also able to create and Page form a Page Lets say you've got a page and wont to have a single item in the page inseat of everything


var newPage = currentPage
                .Select(c => c.Name)
                .ToPage(currentPage.CurrentPageIndex, currentPage.PageSize, currentPage.TotalItemCount, prePaged: true)


By using "prePaged: true", the ToPage will not recreate the page and will use the given collection as the correct page data. For page to know what the total page count is, you will need to give it also to him.