Skip to content

Commit

Permalink
Fix logic for empty supersets
Browse files Browse the repository at this point in the history
  • Loading branch information
a-gubskiy committed Nov 8, 2017
1 parent f2e64c0 commit 3a7be22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/X.PagedList/PagedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PagedList<T, TKey> : BasePagedList<T>
/// <exception cref="ArgumentOutOfRangeException">The specified index cannot be less than zero.</exception>
/// <exception cref="ArgumentOutOfRangeException">The specified page size cannot be less than one.</exception>
public PagedList(IQueryable<T> superset, Expression<Func<T, TKey>> keySelector, int pageNumber, int pageSize)
: base(pageNumber, pageSize, superset.Count())
: base(pageNumber, pageSize, superset?.Count() ?? 0)
{
// add items to internal list
if (TotalItemCount > 0)
Expand All @@ -27,7 +27,7 @@ public PagedList(IQueryable<T> superset, Expression<Func<T, TKey>> keySelector,
}

public PagedList(IQueryable<T> superset, Func<T, TKey> keySelectorMethod, int pageNumber, int pageSize)
: base(pageNumber, pageSize, superset.Count())
: base(pageNumber, pageSize, superset?.Count() ?? 0)
{
if (TotalItemCount > 0)
{
Expand Down Expand Up @@ -69,7 +69,7 @@ public class PagedList<T> : BasePagedList<T>
/// <exception cref="ArgumentOutOfRangeException">The specified index cannot be less than zero.</exception>
/// <exception cref="ArgumentOutOfRangeException">The specified page size cannot be less than one.</exception>
public PagedList(IQueryable<T> superset, int pageNumber, int pageSize)
: base(pageNumber, pageSize, superset.Count())
: base(pageNumber, pageSize, superset?.Count() ?? 0)
{
if (TotalItemCount > 0)
{
Expand Down

0 comments on commit 3a7be22

Please sign in to comment.