* #19775 fixed get user data by applying OrderBy after counting * Apply suggestions from code review --------- Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
@@ -44,13 +44,14 @@ internal sealed class UserDataRepository : IUserDataRepository
|
||||
sql = ApplyFilter(sql, filter);
|
||||
}
|
||||
|
||||
// Fetching the total before applying OrderBy to avoid issue with count subquery.
|
||||
var totalItems = _scopeAccessor.AmbientScope?.Database.Count(sql!) ?? 0;
|
||||
|
||||
sql = sql.OrderBy<UserDataDto>(dto => dto.Identifier); // need to order to skiptake
|
||||
|
||||
List<UserDataDto>? userDataDtos =
|
||||
await _scopeAccessor.AmbientScope?.Database.SkipTakeAsync<UserDataDto>(skip, take, sql)!;
|
||||
|
||||
var totalItems = _scopeAccessor.AmbientScope?.Database.Count(sql!) ?? 0;
|
||||
|
||||
return new PagedModel<IUserData> { Total = totalItems, Items = DtosToModels(userDataDtos) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user