Skip to content

Commit da8d7d2

Browse files
authored
Merge pull request #671 from bcgov/yj
chore: page perf
2 parents 0986661 + 6907749 commit da8d7d2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

server/StrDss.Data/Repositories/RepositoryBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public RepositoryBase(DssDbContext dbContext, IMapper mapper, ICurrentUser curre
3737
public async Task<PagedDto<TOutput>> Page<TInput, TOutput>(IQueryable<TInput> list, int pageSize, int pageNumber, string orderBy, string direction = "", string extraSort = "", bool count = true)
3838
{
3939
var stopwatch = Stopwatch.StartNew();
40+
int? totalRecords = null;
4041

41-
var totalRecords = await list.CountAsync();
42+
if (count) totalRecords = await list.CountAsync();
4243

4344
if (pageNumber <= 0) pageNumber = 1;
4445

server/StrDss.Model/PageDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public int PageNumber
1616

1717
public int PageSize { get; set; }
1818
public int ItemCount { get; set; }
19-
public int TotalCount { get; set; }
19+
public int? TotalCount { get; set; }
2020
public int PageCount => PageSize == 0 ? 1 : ((int)(TotalCount / PageSize) + (TotalCount % PageSize == 0 ? 0 : 1));
2121
public bool HasPreviousPage => PageNumber != 1;
2222
public bool HasNextPage => PageNumber < PageCount;

0 commit comments

Comments
 (0)