SmartPaging 0.0.3

Simple library to implement pagination in .NET.

Install-Package SmartPaging -Version 0.0.3
dotnet add package SmartPaging --version 0.0.3
<PackageReference Include="SmartPaging" Version="0.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartPaging --version 0.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SmartPaging

Simple library to implement pagination in .NET

Install-Package SmartPaging

Usage

After a .OrderBy() you can use the extension method .GetPage() passing the PagingOptions and that's all.

Bellow a sample

using Run.Models;
using SmartPaging;
using System.Linq;
using System.Web.Mvc;

namespace Run.Controllers
{
    public class HomeController : Controller
    {
        private const int DEFAULT_PAGE_SIZE = 10;

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Contacts(int page = 1, int pageSize = DEFAULT_PAGE_SIZE)
        {
            // Create the PagingOptions object
            var pagingOptions = new PagingOptions
            {
                Page = page,
                PageSize = pageSize
            };

            // Generating a sample list to show
            var items = Enumerable.Range(1, 42)
                .Select(s => new Contact
                {
                    Id = s,
                    Name = $"Name {s}",
                    Description = $"Description {s}"
                })
                .ToList();

            // From full list, get the page
            var pageResult = items
                .OrderBy(o => o.Id) // Order the list to paginate
                .GetPage(pagingOptions) // Get page with PagingOptions before created
                .ToList();

            var pagedResult = new PagedResult<Contact>
            {
                Items = pageResult, // Items of a one page
                Count = items.Count // Total of items from full list
            };

            return Json(pagedResult, JsonRequestBehavior.AllowGet);
        }
    }
}

The front end needs to send the page number and the page size, or just the page number, to get the next page.

Danke

SmartPaging

Simple library to implement pagination in .NET

Install-Package SmartPaging

Usage

After a .OrderBy() you can use the extension method .GetPage() passing the PagingOptions and that's all.

Bellow a sample

using Run.Models;
using SmartPaging;
using System.Linq;
using System.Web.Mvc;

namespace Run.Controllers
{
    public class HomeController : Controller
    {
        private const int DEFAULT_PAGE_SIZE = 10;

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Contacts(int page = 1, int pageSize = DEFAULT_PAGE_SIZE)
        {
            // Create the PagingOptions object
            var pagingOptions = new PagingOptions
            {
                Page = page,
                PageSize = pageSize
            };

            // Generating a sample list to show
            var items = Enumerable.Range(1, 42)
                .Select(s => new Contact
                {
                    Id = s,
                    Name = $"Name {s}",
                    Description = $"Description {s}"
                })
                .ToList();

            // From full list, get the page
            var pageResult = items
                .OrderBy(o => o.Id) // Order the list to paginate
                .GetPage(pagingOptions) // Get page with PagingOptions before created
                .ToList();

            var pagedResult = new PagedResult<Contact>
            {
                Items = pageResult, // Items of a one page
                Count = items.Count // Total of items from full list
            };

            return Json(pagedResult, JsonRequestBehavior.AllowGet);
        }
    }
}

The front end needs to send the page number and the page size, or just the page number, to get the next page.

Danke

  • .NETCoreApp 1.0

  • .NETCoreApp 1.1

  • .NETCoreApp 2.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.3 472 12/15/2017
0.0.2 488 11/15/2016
0.0.1 328 11/14/2016