Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions UnitOfWork/Collections/IQueryablePageListExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -28,6 +29,18 @@ public static class IQueryablePageListExtensions
}

var count = await source.CountAsync(cancellationToken).ConfigureAwait(false);

if (count == 0)
return new PagedList<T>()
{
PageIndex = pageIndex,
PageSize = pageSize,
IndexFrom = indexFrom,
TotalCount = count,
Items = new List<T>(),
TotalPages = 0
};

var items = await source.Skip((pageIndex - indexFrom) * pageSize)
.Take(pageSize).ToListAsync(cancellationToken).ConfigureAwait(false);

Expand Down