From 4e47a3a0ef50a25b03ade77df3b4e824f94c0970 Mon Sep 17 00:00:00 2001 From: Biarity Date: Wed, 7 Feb 2018 14:44:55 +1000 Subject: [PATCH 1/3] Redocument non-generic version --- README.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 847fc07..e6d32c9 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,9 @@ We'll use Sieve to add sorting, filtering, and pagination capabilities when GET- ### 1. Add required services -Inject the `SieveProcessor` service for each entity you'd like to use Sieve with. -So to use Sieve with `Post`s, in `ConfigureServices` in `Startup.cs` add: +Inject the `SieveProcessor` service. So in `Startup.cs` add: ``` -services.AddScoped, SieveProcessor>(); +services.AddScoped(); ``` ### 2. Tell Sieve which properties you'd like to sort/filter in your models @@ -44,8 +43,7 @@ There is also the `name` parameter that you can use to have a different name for ### 3. Get sort/filter/page queries by using the Sieve model in your controllers In the action that handles returning Posts, use `SieveModel` to get the sort/filter/page query. -Apply it to your data by injecting `SieveProcessor` into the controller and using its `ApplyAll` method. -For instance: +Apply it to your data by injecting `SieveProcessor` into the controller and using its `ApplyAll` method. So for instance: ``` [HttpGet] public JsonResult GetPosts(SieveModel sieveModel) @@ -63,16 +61,16 @@ There are also `ApplySorting`, `ApplyFiltering`, and `ApplyPagination` methods. ### Add custom sort/filter methods -If you want to add custom sort/filter methods, inject `ISieveCustomSortMethods` or `ISieveCustomFilterMethods` with the implementation being a class that has custom sort/filter methods for `TEntity`. +If you want to add custom sort/filter methods, inject `ISieveCustomSortMethods` or `ISieveCustomFilterMethods` with the implementation being a class that has custom sort/filter methods that Sieve will through. For instance: ``` -services.AddScoped, SieveCustomSortMethodsOfPosts>(); -services.AddScoped, SieveCustomFilterMethodsOfPosts>(); +services.AddScoped(); +services.AddScoped(); ``` Where `SieveCustomSortMethodsOfPosts` for example is: ``` -public class SieveCustomSortMethodsOfPosts : ISieveCustomSortMethods +public class SieveCustomSortMethods : ISieveCustomSortMethods { public IQueryable Popularity(IQueryable source, bool useThenBy, bool desc) // The method is given an indicator of weather to use ThenBy(), and if the query is descending { @@ -86,9 +84,9 @@ public class SieveCustomSortMethodsOfPosts : ISieveCustomSortMethods } } ``` -And `SieveCustomFilterMethodsOfPosts`: +And `SieveCustomFilterMethods`: ``` -public class SieveCustomFilterMethodsOfPosts : ISieveCustomFilterMethods +public class SieveCustomFilterMethods : ISieveCustomFilterMethods { public IQueryable IsNew(IQueryable source, string op, string value) // The method is given the {Operator} & {Value} { From cf9cb4160ce7c52e628a74c54a9091a651e78c6c Mon Sep 17 00:00:00 2001 From: Biarity Date: Wed, 7 Feb 2018 14:51:34 +1000 Subject: [PATCH 2/3] Injecting interface unnecessary --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e6d32c9..85f2d22 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ We'll use Sieve to add sorting, filtering, and pagination capabilities when GET- Inject the `SieveProcessor` service. So in `Startup.cs` add: ``` -services.AddScoped(); +services.AddScoped(); ``` ### 2. Tell Sieve which properties you'd like to sort/filter in your models @@ -65,8 +65,8 @@ If you want to add custom sort/filter methods, inject `ISieveCustomSortMethods` For instance: ``` -services.AddScoped(); -services.AddScoped(); +services.AddScoped(); +services.AddScoped(); ``` Where `SieveCustomSortMethodsOfPosts` for example is: ``` From af3da58ce147f7f0d77e4dfce796392dc2fdde03 Mon Sep 17 00:00:00 2001 From: Biarity Date: Wed, 7 Feb 2018 16:13:47 +1000 Subject: [PATCH 3/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85f2d22..0cd4d49 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,8 @@ If you want to add custom sort/filter methods, inject `ISieveCustomSortMethods` For instance: ``` -services.AddScoped(); -services.AddScoped(); +services.AddScoped(); +services.AddScoped(); ``` Where `SieveCustomSortMethodsOfPosts` for example is: ```