Skip to content

Commit

Permalink
📖
Browse files Browse the repository at this point in the history
  • Loading branch information
mrahhal committed Jul 4, 2024
1 parent 9d624fe commit 087442b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Learn about why the standard offset based pagination (`Take().Skip()`) is bad in

Check the [benchmarks](#benchmarks) section below for a quick look at the different performance characteristics between offset and keyset.

> **Note**
> [!NOTE]
> If you're using ASP.NET Core, you can use [MR.AspNetCore.Pagination](https://github.com/mrahhal/MR.AspNetCore.Pagination) which wraps this package and offers an easier to consume keyset pagination behavior with additional features for ASP.NET Core. This is a lower level library that implements keyset pagination for EF Core.
## Usage
Expand Down Expand Up @@ -44,7 +44,7 @@ Here's a small visual representation:

The columns and their configured order are used to order the data, and then the direction decides if we're getting the data before or after the reference row.

> **Warning**
> [!WARNING]
> You'll want to reverse the result whenever you use `KeysetPaginationDirection.Backward` to get the proper order of the data, since walking `Backward` gives results in the opposite order to the configured columns order. There's a helper method on `KeysetContext` for this, shown in a snippet later.
`KeysetPaginate` returns a context object which you can use to get secondary info and get the data result.
Expand Down Expand Up @@ -75,7 +75,7 @@ KeysetPaginate(
)
```

> **Important**
> [!IMPORTANT]
> Make sure to read the "Deterministic keysets" and "Indexing" sections for important notes about configuring keysets.
## Common patterns
Expand Down Expand Up @@ -207,7 +207,7 @@ var hasNext = await keysetContext.HasNextAsync(users);

`HasPreviousAsync`/`HasNextAsync` are useful when you want to know when to render Previous/Next (Older/Newer) buttons.

> **Note**
> [!NOTE]
> The reference/data these methods accept are loosely typed to allow flexibility when projecting your models (to DTOs for example). For more info check [this document](docs/loose-typing.md).
Here's another example showing how to obtain the total count for the data to display somewhere:
Expand Down Expand Up @@ -316,7 +316,7 @@ KeysetPaginate(

In this case you'll want to create a composite index on `Score` + `Id`, but make sure they're compatible with the order above. i.e You should make the index descending on `Score` and ascending on `Id` (or the opposite) for it to be effective.

> **Note**
> [!NOTE]
> Refer to [this document](https://docs.microsoft.com/en-us/ef/core/modeling/indexes) on how to create indexes with EF Core. Note that support for specifying sort order in a composite index was introduced in EF Core 7.0.
## Benchmarks
Expand Down

0 comments on commit 087442b

Please sign in to comment.