From abb7029c70a83db008dc1ee3390166b6dac37e62 Mon Sep 17 00:00:00 2001 From: Biarity Date: Thu, 14 Jun 2018 18:50:19 +1000 Subject: [PATCH] Fixes #28 --- Sieve/Services/SieveProcessor.cs | 5 +++++ Sieve/Sieve.csproj | 6 +++--- SieveUnitTests/General.cs | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Sieve/Services/SieveProcessor.cs b/Sieve/Services/SieveProcessor.cs index c542a38..6070938 100644 --- a/Sieve/Services/SieveProcessor.cs +++ b/Sieve/Services/SieveProcessor.cs @@ -174,6 +174,7 @@ namespace Sieve.Services filterTerm.Value }; result = ApplyCustomMethod(result, filterTermName, _customFilterMethods, parameters, dataForCustomMethods); + } } if (outerExpression == null) @@ -181,6 +182,10 @@ namespace Sieve.Services outerExpression = innerExpression; continue; } + if (innerExpression == null) + { + continue; + } outerExpression = Expression.And(outerExpression, innerExpression); } return outerExpression == null diff --git a/Sieve/Sieve.csproj b/Sieve/Sieve.csproj index 8b700b9..fc4601e 100644 --- a/Sieve/Sieve.csproj +++ b/Sieve/Sieve.csproj @@ -1,8 +1,8 @@ - + netstandard2.0 - 2.1.0 + 2.1.2 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 - Fix OR conditions and better SQL Server support + Fix issue #28 true true Biarity diff --git a/SieveUnitTests/General.cs b/SieveUnitTests/General.cs index ee9459b..0d09912 100644 --- a/SieveUnitTests/General.cs +++ b/SieveUnitTests/General.cs @@ -152,6 +152,34 @@ namespace SieveUnitTests Assert.IsTrue(result.Count() == 3); } + [TestMethod] + public void CustomFiltersMixedWithUsualWork1() + { + var model = new SieveModel() + { + Filters = "Isnew,CategoryId==2", + }; + + var result = _processor.Apply(model, _posts); + + Assert.IsTrue(result.Any(p => p.Id == 3)); + Assert.IsTrue(result.Count() == 1); + } + + [TestMethod] + public void CustomFiltersMixedWithUsualWork2() + { + var model = new SieveModel() + { + Filters = "CategoryId==2,Isnew", + }; + + var result = _processor.Apply(model, _posts); + + Assert.IsTrue(result.Any(p => p.Id == 3)); + Assert.IsTrue(result.Count() == 1); + } + [TestMethod] public void MethodNotFoundExceptionWork() {