This commit is contained in:
Biarity 2018-06-14 18:50:19 +10:00
parent d149721627
commit abb7029c70
3 changed files with 36 additions and 3 deletions

View File

@ -174,6 +174,7 @@ namespace Sieve.Services
filterTerm.Value filterTerm.Value
}; };
result = ApplyCustomMethod(result, filterTermName, _customFilterMethods, parameters, dataForCustomMethods); result = ApplyCustomMethod(result, filterTermName, _customFilterMethods, parameters, dataForCustomMethods);
} }
} }
if (outerExpression == null) if (outerExpression == null)
@ -181,6 +182,10 @@ namespace Sieve.Services
outerExpression = innerExpression; outerExpression = innerExpression;
continue; continue;
} }
if (innerExpression == null)
{
continue;
}
outerExpression = Expression.And(outerExpression, innerExpression); outerExpression = Expression.And(outerExpression, innerExpression);
} }
return outerExpression == null return outerExpression == null

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Version>2.1.0</Version> <Version>2.1.2</Version>
<Description>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/ <Description>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/
</Description> </Description>
<Copyright>Copyright 2018</Copyright> <Copyright>Copyright 2018</Copyright>
@ -10,7 +10,7 @@
<PackageProjectUrl>https://github.com/Biarity/Sieve</PackageProjectUrl> <PackageProjectUrl>https://github.com/Biarity/Sieve</PackageProjectUrl>
<PackageIconUrl>https://emojipedia-us.s3.amazonaws.com/thumbs/240/twitter/120/alembic_2697.png</PackageIconUrl> <PackageIconUrl>https://emojipedia-us.s3.amazonaws.com/thumbs/240/twitter/120/alembic_2697.png</PackageIconUrl>
<RepositoryUrl></RepositoryUrl> <RepositoryUrl></RepositoryUrl>
<PackageReleaseNotes>Fix OR conditions and better SQL Server support</PackageReleaseNotes> <PackageReleaseNotes>Fix issue #28</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>Biarity</Authors> <Authors>Biarity</Authors>

View File

@ -152,6 +152,34 @@ namespace SieveUnitTests
Assert.IsTrue(result.Count() == 3); 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] [TestMethod]
public void MethodNotFoundExceptionWork() public void MethodNotFoundExceptionWork()
{ {