Skip to content

Commit 4d6ad42

Browse files
authored
📖
1 parent 8f274c8 commit 4d6ad42

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ Here's another example showing how to obtain the total count for the data to dis
183183
```cs
184184
// Assuming we're in an api that should return admin users.
185185
186-
// Do the initial query first.
186+
// Prepare the base query first.
187187
var query = dbContext.Users.Where(x => x.IsAdmin);
188188

189189
// This will be the count of all admins.
190190
var count = await query.CountAsync();
191191

192192
// And then we apply keyset pagination at the end.
193-
// You can optionally use the context object too as explained above to get additional info.
194-
var keysetContext = dbContext.Users.KeysetPaginate(...);
195-
var users = await keysetContext.Query
193+
// `KeysetPaginate` adds ordering and more predicates to the query so we have to get the count before we apply it.
194+
var keysetContext = query.KeysetPaginate(...);
195+
var admins = await keysetContext.Query
196196
.Take(20)
197197
.ToListAsync();
198-
keysetContext.EnsureCorrectOrder(users);
199-
```
200198

201-
`KeysetPaginate` adds ordering and more predicates to the query so we have to get the count before we apply it.
199+
// You can optionally use the context object too as explained above to get additional info.
200+
keysetContext.EnsureCorrectOrder(admins);
201+
```
202202

203203
## Avoiding skipping over data
204204

0 commit comments

Comments
 (0)