Skip to content

enisgurkann/ENPAGER

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
      />