10000 feat: allow null fot paging params in paged list constructor · cnblogs/Architecture@52f17b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52f17b6

Browse files
committed
feat: allow null fot paging params in paged list constructor
1 parent ef3fce9 commit 52f17b6

File tree

1 file changed

+12
-4
lines changed
  • src/Cnblogs.Architecture.Ddd.Infrastructure.Abstractions

1 file changed

+12
-4
lines changed

src/Cnblogs.Architecture.Ddd.Infrastructure.Abstractions/PagedList.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,21 @@ public PagedList(IReadOnlyCollection<T> items, int pageIndex, int pageSize, int
3838
/// <param name="items">包含的元素。</param>
3939
/// <param name="pagingParams">分页参数。</param>
4040
/// <param name="totalCount">元素总数。</param>
41-
public PagedList(IReadOnlyCollection<T> items, PagingParams pagingParams, int totalCount)
41+
public PagedList(IReadOnlyCollection<T> items, PagingParams? pagingParams, int totalCount)
4242
{
4343
Items = items;
4444
TotalCount = totalCount;
45-
var (pageIndex, pageSize) = pagingParams;
46-
PageIndex = pageIndex;
47-
PageSize = pageSize;
45+
if (pagingParams is null)
46+
{
47+
PageIndex = 1;
48+
PageSize = totalCount;
49+
}
50+
else
51+
{
52+
var (pageIndex, pageSize) = pagingParams;
53+
PageIndex = pageIndex;
54+
PageSize = pageSize;
55+
}
4856
}
4957

5058
/// <summary>

0 commit comments

Comments
 (0)
0