-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated docs to explain sorting and pagination
- Loading branch information
1 parent
e7cf494
commit b516654
Showing
3 changed files
with
3,963 additions
and
4,451 deletions.
There are no files selected for viewing
File renamed without changes.
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,50 @@ | ||
# Sorting & Pagination | ||
|
||
The DatabaseRepository methods `IterateAsync` and `QueryAsync` support sorting and pagination to allow the user to retrieve a subset of the results. | ||
|
||
## Sorting | ||
|
||
The generic `Sorting<>` objects allows you to define a sorting on a given properties (multiple properties helps you e.g. to order first on firstname and for all entities which have the same firstname, you can define that they should be ordered by the id property). The sorting can be ascending or descending. | ||
|
||
```csharp | ||
var sorting = new Sorting<User>() | ||
.OrderBy(x => x.FirstName) | ||
.OrderByDescending(x => x.Id); | ||
|
||
var sortedUsers = _userRepository.QueryAsync( | ||
x => true, | ||
sorting); | ||
``` | ||
|
||
## Pagination | ||
|
||
The `Pagination` objects allows you to define skip and take values to retrieve a subset of the results. | ||
|
||
```csharp | ||
var pagination = new Pagination() | ||
.Skip(10) | ||
.Take(10); | ||
|
||
var pagedUsers = _userRepository.QueryAsync( | ||
x => true, | ||
pagination); | ||
``` | ||
|
||
## Sorting & Pagination | ||
|
||
The `IterateAsync` and `QueryAsync` methods support sorting and pagination. You can combine both to retrieve a subset of the results in a sorted order. | ||
|
||
```csharp | ||
var sorting = new Sorting<User>() | ||
.OrderBy(x => x.FirstName) | ||
.OrderByDescending(x => x.Id); | ||
|
||
var pagination = new Pagination() | ||
.Skip(10) | ||
.Take(10); | ||
|
||
var sortedPagedUsers = _userRepository.QueryAsync( | ||
x => true, | ||
sorting, | ||
pagination); | ||
``` |
Oops, something went wrong.