From 35167075bfcd48212293a0a9e7f1a1cac3ca29b6 Mon Sep 17 00:00:00 2001 From: Biarity Date: Fri, 18 Jan 2019 20:54:55 +1000 Subject: [PATCH] Document #51 --- README.md | 26 ++++++++++++++++++++++++++ Sieve/Sieve.csproj | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a98f0af..5988048 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,32 @@ Notes: * Here's a [good example on how to work with enumerables](https://github.com/Biarity/Sieve/issues/2) * Another example on [how to do OR logic](https://github.com/Biarity/Sieve/issues/8) +### Nested objects +You can filter/sort on a nested object's property by marking the property using the Fluent API. +Marking via attributes not currently supported. + +For example, using this object model: + +```C# +public class Post { + public User creator { get; set; } +} + +public class User { + public string Name { get; set; } +} +``` + +Mark `Post.User` to be filterable: +```C# +// in MapProperties +mapper.Property(p => p.User.Name) + .CanFilter(); +``` + +Now you can make requests such as: `filters=User.Name==specific_name` + + ### Creating your own DSL You can replace this DSL with your own (eg. use JSON instead) by implementing an [ISieveModel](https://github.com/Biarity/Sieve/blob/master/Sieve/Models/ISieveModel.cs). You can use the default [SieveModel](https://github.com/Biarity/Sieve/blob/master/Sieve/Models/SieveModel.cs) for reference. diff --git a/Sieve/Sieve.csproj b/Sieve/Sieve.csproj index 91670c0..a4a926b 100644 --- a/Sieve/Sieve.csproj +++ b/Sieve/Sieve.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 2.3 + 2.3.1 Sieve is a simple, clean, and extensible framework for .NET Core that adds sorting, filtering, and pagination functionality out of the box. Most common use case would be for serving ASP.NET Core GET queries. Documentation available on GitHub: https://github.com/Biarity/Sieve/ Copyright 2018 @@ -10,7 +10,7 @@ https://github.com/Biarity/Sieve https://emojipedia-us.s3.amazonaws.com/thumbs/240/twitter/120/alembic_2697.png - Negated operators (PR SuperGouge:negation-operator) + Filtering and sorting for nested objects (#51) true true Biarity