-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work in progress for RepoDb offset paging, but BatchQuery is not work…
…ing as originally thought, will have to re-factor to implement a Skip/Take query manually!
- Loading branch information
1 parent
4d9b220
commit fc8fbcd
Showing
7 changed files
with
84 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
SELECT * FROM StarWarsCharacters ORDER BY Id ASC | ||
|
||
DECLARE @page AS INT = 1; | ||
DECLARE @rowsPerBatch AS INT = 8; | ||
|
||
SELECT TOP((@page + 1)*@rowsPerBatch) ROW_NUMBER() OVER (ORDER BY Id ASC) AS [RowNumber], [Id], [Name] FROM [StarWarsCharacters] ORDER BY Id ASC; | ||
|
||
--Modeled from RepoDB's BatchQuery logic (query builder) | ||
WITH CTE AS (SELECT TOP((@page + 1)*@rowsPerBatch) ROW_NUMBER() OVER (ORDER BY Id ASC) AS [RowNumber], [Id], [Name] FROM [StarWarsCharacters] ORDER BY Id ASC) | ||
SELECT [Id], [Name] FROM CTE WHERE ([RowNumber] BETWEEN ((@page * @rowsPerBatch) + 1) AND ((@page + 1) * @rowsPerBatch)); | ||
|
||
SELECT | ||
BetweenSql = 'Between ' + CONVERT(VARCHAR(5), ((@page * @rowsPerBatch) + 1)) + ' and ' + CONVERT(VARCHAR(5), ((@page + 1) * @rowsPerBatch)); |