Last active
June 19, 2020 09:37
-
-
Save johnbabb/fc1db5f30a7310bdf51799045c7c7503 to your computer and use it in GitHub Desktop.
Code to covert page and page size into sql to skip rows and take rows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
int? page = 3; | |
int? pageSize = 25; | |
if (page.HasValue && pageSize.HasValue) | |
{ | |
var skip = (page.Value - 1) * pageSize.Value; | |
var take = pageSize.Value; | |
skip = skip < 0 ? 0 : skip; | |
Console.WriteLine(skip); | |
Console.WriteLine(take); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment