mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-22 13:32:33 +01:00
Max page size (#9)
This commit is contained in:
parent
af1fa00fb1
commit
69f21ca695
@ -11,6 +11,8 @@ namespace Sieve.Models
|
||||
|
||||
public int DefaultPageSize { get; set; } = 0;
|
||||
|
||||
public int MaxPageSize { get; set; } = 0;
|
||||
|
||||
public bool ThrowExceptions { get; set; } = false;
|
||||
}
|
||||
}
|
@ -239,11 +239,12 @@ namespace Sieve.Services
|
||||
{
|
||||
var page = model?.Page ?? 1;
|
||||
var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize;
|
||||
var maxPageSize = _options.Value.MaxPageSize > 0 ? _options.Value.MaxPageSize : pageSize;
|
||||
|
||||
result = result.Skip((page - 1) * pageSize);
|
||||
|
||||
if (pageSize > 0)
|
||||
result = result.Take(pageSize);
|
||||
result = result.Take(Math.Min(pageSize, maxPageSize));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user