Code Monkey home page Code Monkey logo

pagesort.efcore's Introduction

PageSort

Maintainability Build status

What is PageSort

PageSort is a simple .Net Standard library that is built to ease paging, sort and filtering of IQueryable collections. This is the main repository for PageSort and its extensions.

Getting Started

You need to reference the PageSort namespace in your project.

Using PageSort;

Paging Example

Using the IQueryable Extension

collection - collection.Page(1, 20);

The Page IQueryable extension takes the pageNumber and the pageSize. It returns paged collection of the specified source query.

Using the GeneratePaging Method.
var pageQuery = new PageQuery{
    PageNumber = 1,
    PageSize = 20,
};

var collection = new IQueryable<Student>();
var pagedCollection = GeneratePaging(collection, pageQuery);

The GeneratePaging() method takes an IQueryable collection and a PageQuery object. This method returns a PageResult object.

Sorting Example

Using the IQueryable Extension.
var sortedCollection = collection.OrderByProperty(sortProperty);

var sortedCollection = collection.OrderByDescendingProperty(sortProperty);

Page and Sort at ago

You can also use the GeneratePaging Method to perform both paging and sorting Operations on a collection

var pageQuery = new PageQuery{
    PageNumber = 1,
    PageSize = 20,
    SortProperty = "DateOfBirth",
    SortOrder = ListSortDirection.Descending
};

var collection = new IQueryable<Student>();
var pagedCollection = GeneratePaging(collection, pageQuery);

PageResult

Below is an example of a PageResult

{
    CurrentPage = 1,
    PageSize = 20,
    TotalCount = 200,
    TotalPages = 10,
    Collection = collection,
    PreviousPage = true,
    NextPage = true

}
  • CurrentPage is an integer that represents the current page of the collection that is being returned
  • PageSize is the size of the collection that is to be returned per page.
  • TotalCount is the total number of Items in the collection for which paging is done.
  • TotalPages is the total number of pages that can be generated from the collection. This value is dependant on the PageSize value that is passed.
  • Collection is the list of items in the current page.
  • PreviousPage is a boolean that tells whether there are previous pages or not. This is set to false if PageNumber is 1 or the collection can only have one page.
  • NextPage is a boolean that tells whether there are more pages or not. It is set to false if there is only one page, or we are on the last page of the collection

Installing

First, install NuGet. Then, install PageSort from the package manager console:

PM> Install-Package PageSort

You can also install the PageSort Package using the .NET CLI

dotnet add package PageSort

You can also add the package reference to the project file of your project.

<PackageReference Include="PageSort Version="1.0.2" />

Do you have an issue?

If you run into problems, please share it with me via email at [email protected]

License, e.t.c.

PageSort is Copyright © 2019 Stanley Barnabas Nagwere and other contributors under the MIT license.

pagesort.efcore's People

Watchers

 avatar  avatar

Forkers

dreadedcoder

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.