Skip to content

Commit

Permalink
docs: add order by nullable types
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezanet committed Mar 1, 2022
1 parent 0d0332b commit 2e832fe
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/guide/ordering.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,31 @@ builder.AddOrderBy("Id desc, FirstName asc, LastName");
```
:::
::::

## Order By Nullable types

Sometimes we need to order by nullable types, for example:

``` csharp
personsRepo.OrderBy(p => p.BirthDate.HasValue)
```

to support this behavior, you can use Gridify special characters (`?` or `!`) after the property name.

e.g:

To achieve the `personsRepo.OrderBy(p => p.BirthDate.HasValue)` query, you can use `?`:

``` csharp
var x = personsRepo.ApplyOrdering("BirthDate?");
```

and for `personsRepo.OrderBy(p => !p.BirthDate.HasValue)`, you can use `!`:

``` csharp
var x = personsRepo.ApplyOrdering("BirthDate!");
```

::: warning
These nullable characters only work on nullable types.
:::

0 comments on commit 2e832fe

Please sign in to comment.