phonebook_server/phonebook_server/Classes/Pagination/PagedList.cs
/// <summary>
///     Creates asynchronously a pagination list, given a <see cref="IQueryable{T}" />,
///     the current pageNumber and the total size of elements for each page
/// </summary>
Creates asynchronously a pagination list, given a ,
the current pageNumber and the total size of elements for each page
Creates asynchronously a pagination list given a the current pageNumber and the total size of elements for each page
public static async Task<PagedList<T>> CreateAsync(IQueryable<T> sourceQuery, int pageNumber, int pageSize)
        {
            var count = await sourceQuery.CountAsync();
            var items = await sourceQuery
                .Skip((pageNumber - 1) * pageSize)
                .Take(pageSize)
                .ToListAsync();
            return new PagedList<T>(items, count, pageNumber, pageSize);
        }
public static async Task < PagedList < T > > CreateAsync ( IQueryable < T > sourceQuery , int pageNumber , int pageSize ) { var count = await sourceQuery . CountAsync ( ) ; var items = await sourceQuery . Skip ( ( pageNumber - 1 ) * pageSize ) . Take ( pageSize ) . ToListAsync ( ) ; return new PagedList < T > ( items , count , pageNumber , pageSize ) ; }
Creates asynchronously a pagination list, given a ,
the current pageNumber and the total size of elements for each page
Creates asynchronously a pagination list given a the current pageNumber and the total size of elements for each page
sourceQuery
IQueryable<T>
pageNumber
int
pageSize
int