mrahhal / MR.AspNetCore.Pagination

Pagination for ASP.NET Core.
MIT License
62 stars 3 forks source link

Remove auto parsing of int for after/before #5

Closed mrahhal closed 2 years ago

mrahhal commented 2 years ago

Today we try to automatically parse the id in after/value as an int: https://github.com/mrahhal/MR.AspNetCore.Pagination/blob/9a9b137c7cf081d9da8566dd7340c24d63857b96/src/MR.AspNetCore.Pagination/PaginationService.cs#L305-L329

This is problematic for cases when the id is not an int (maybe a string) but it looks like one. We should completely remove this behavior, the caller should parse the id instead (it'll always be a string now):

await _paginationService.KeysetPaginateAsync(
    query,
    b => b.Descending(x => x.Created),
    async id => await _dbContext.Posts.FindAsync(int.Parse(id)));