Only Skip when pageSize > 0

This commit is contained in:
Jan Verley 2019-05-09 11:29:39 +02:00 committed by Jan Verley
parent 9f6163d318
commit 567cd67c7f

View File

@ -337,10 +337,9 @@ namespace Sieve.Services
var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize; var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize;
var maxPageSize = _options.Value.MaxPageSize > 0 ? _options.Value.MaxPageSize : pageSize; var maxPageSize = _options.Value.MaxPageSize > 0 ? _options.Value.MaxPageSize : pageSize;
result = result.Skip((page - 1) * pageSize);
if (pageSize > 0) if (pageSize > 0)
{ {
result = result.Skip((page - 1) * pageSize);
result = result.Take(Math.Min(pageSize, maxPageSize)); result = result.Take(Math.Min(pageSize, maxPageSize));
} }