mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-22 13:32:33 +01:00
Custom filters/sorts case-insensitivity
This commit is contained in:
parent
bafee2314e
commit
3068c476e1
@ -284,7 +284,8 @@ namespace Sieve.Services
|
|||||||
private IQueryable<TEntity> ApplyCustomMethod<TEntity>(IQueryable<TEntity> result, string name, object parent, object[] parameters, object[] optionalParameters = null)
|
private IQueryable<TEntity> ApplyCustomMethod<TEntity>(IQueryable<TEntity> result, string name, object parent, object[] parameters, object[] optionalParameters = null)
|
||||||
{
|
{
|
||||||
var customMethod = parent?.GetType()
|
var customMethod = parent?.GetType()
|
||||||
.GetMethod(name);
|
.GetMethod(name,
|
||||||
|
_options.Value.CaseSensitive ? BindingFlags.Default : BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
|
||||||
|
|
||||||
if (customMethod != null)
|
if (customMethod != null)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Sieve</id>
|
<id>Sieve</id>
|
||||||
<version>1.3.8</version>
|
<version>1.3.9</version>
|
||||||
<title>Sieve</title>
|
<title>Sieve</title>
|
||||||
<authors>Biarity</authors>
|
<authors>Biarity</authors>
|
||||||
<owners>Biarity</owners>
|
<owners>Biarity</owners>
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<description>
|
<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/
|
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>
|
||||||
<releaseNotes>Filter before sort</releaseNotes>
|
<releaseNotes>Fluent API v1 and case-insensitive operators</releaseNotes>
|
||||||
<copyright>Copyright 2018</copyright>
|
<copyright>Copyright 2018</copyright>
|
||||||
<tags>aspnetcore filter sort page paginate sieve search</tags>
|
<tags>aspnetcore filter sort page paginate sieve search</tags>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -87,6 +87,20 @@ namespace SieveUnitTests
|
|||||||
Assert.AreEqual(result.First().Id, 1);
|
Assert.AreEqual(result.First().Id, 1);
|
||||||
Assert.IsTrue(result.Count() == 1);
|
Assert.IsTrue(result.Count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CustomFiltersWork()
|
||||||
|
{
|
||||||
|
var model = new SieveModel()
|
||||||
|
{
|
||||||
|
Filters = "Isnew",
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = _processor.ApplyFiltering(model, _posts);
|
||||||
|
|
||||||
|
Assert.IsFalse(result.Any(p => p.Id == 0));
|
||||||
|
Assert.IsTrue(result.Count() == 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,7 @@ namespace SieveUnitTests.Services
|
|||||||
{
|
{
|
||||||
public IQueryable<Post> IsNew(IQueryable<Post> source, string op, string value)
|
public IQueryable<Post> IsNew(IQueryable<Post> source, string op, string value)
|
||||||
{
|
{
|
||||||
var result = source.Where(p => p.LikeCount < 100 &&
|
var result = source.Where(p => p.LikeCount < 100);
|
||||||
p.CommentCount < 5);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
### 1. Pack:
|
### 1. Pack:
|
||||||
```
|
```
|
||||||
dotnet pack Sieve.csproj -c Release -o . /p:PackageVersion=1.3.8
|
dotnet pack Sieve.csproj -c Release -o . /p:PackageVersion=1.3.9
|
||||||
```
|
```
|
||||||
Don't forget to change version since nuget packages are immutable (add one to the nuget current).
|
Don't forget to change version since nuget packages are immutable (add one to the nuget current).
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ Also don't forget updaing `releaseNotes` in nuspec.
|
|||||||
|
|
||||||
### 3. Publish:
|
### 3. Publish:
|
||||||
```
|
```
|
||||||
nuget push Sieve.1.3.8.nupkg API_KEY -Source https://api.nuget.org/v3/index.json
|
nuget push Sieve.1.3.9.nupkg API_KEY -Source https://api.nuget.org/v3/index.json
|
||||||
```
|
```
|
||||||
Replace API_KEY with one you get from nuget's website.
|
Replace API_KEY with one you get from nuget's website.
|
||||||
Also don't forget to replace corresponding version.
|
Also don't forget to replace corresponding version.
|
||||||
|
Loading…
Reference in New Issue
Block a user