/ENPAGER

ENPAGER - Entity Framework Simple Pager Extention

Primary LanguageC#Apache License 2.0Apache-2.0

ENPAGER - EFCORE Pager Tool

GitHub GitHub Repo stars GitHub last commit Contributors Discussions Nuget version Nuget downloads

It is a plugin that allows us to quickly paginate while using Entity framework.

Methods

ToPagedListAsync,ToPagedList

Entity Framework Core Pager Provider Usage

PM> Install-Package ENPAGER
PM> Standart Paging
        var totalCount = await await _context.Where(x => x.Name.Contains('Enis')).CountAsync();
        var items = await await _context
                          .Customers
                          .Where(x => x.Name.Contains('Enis'))
                          .Skip((pageIndex - 1) * pageSize)
                          .Take(pageSize)
                          .ToListAsync();
        int totalPages = (int) Math.Ceiling((double) TotalCount / PageSize);
        bool hasPreviousPage = pageIndex > 1;
        bool hasNextPage = pageIndex < totalPages;
        var customersPagedList = new {
                                      PageIndex = pageIndex,
                                      PageSize = pageSize,
                                      TotalCount = totalCount,
                                      TotalPages = totalPages,
                                      HasPreviousPage = hasPreviousPage,
                                      HasNextPage = hasNextPage
                                     };
PM> Using ToPagedListAsync
        var customersPagedList = await _context
        .Customers
        .Where(x => x.Name.Contains('Enis'))
        .ToPagedListAsync(pageIndex,pageSize);
 

View Usage

PM> ViewImport.cshtml
    @addTagHelper *, ENPAGER 
PM> Using FrontEnd Pager {Using View}.cshtml
      <EnPager total-items="Model.customer.TotalCount"
          total-pages="Model.customer.TotalPages"
          page="Model.customer.PageIndex"
          page-size="Model.customer.PageSize"
          show-active-link="true"
      />