Skip to content

Commit

Permalink
Updated docs to explain sorting and pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianKuesters committed Aug 29, 2023
1 parent e7cf494 commit b516654
Show file tree
Hide file tree
Showing 3 changed files with 3,963 additions and 4,451 deletions.
File renamed without changes.
50 changes: 50 additions & 0 deletions docs/public/docs-general/05-sorting-pagination.md
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);
```
Loading

0 comments on commit b516654

Please sign in to comment.