Skip to content

Commit

Permalink
Merge pull request #67 from trenoncourt/develop
Browse files Browse the repository at this point in the history
fix: add decimal management in query string
  • Loading branch information
trenoncourt authored Aug 5, 2018
2 parents 4f88610 + b92f3cf commit dedf2fc
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sample/AutoQueryable.Sample.EfCore/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void Seed(AutoQueryableDbContext context)
Color = i % 2 == 0 ? "red" : "black",
ProductCategory = i % 2 == 0 ? redCategory : blackCategory,
ProductModel = model1,
ListPrice = i,
ListPrice = (decimal) (i / 5.0),
Name = $"Product {i}",
ProductNumber = Guid.NewGuid().ToString(),
Rowguid = Guid.NewGuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</Description>
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</AssemblyTitle>
<VersionPrefix>1.7.0</VersionPrefix>
<Version>2.0.3-beta</Version>
<Version>2.0.4-beta</Version>
<Authors>Thibaut Renoncourt</Authors>
<TargetFramework>net46</TargetFramework>
<AssemblyName>AutoQueryable.AspNet.Filter</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion src/AutoQueryable.AspNet/AutoQueryable.AspNet.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<Version>2.0.3-beta</Version>
<Version>2.0.4-beta</Version>
<PackageLicenseUrl>https://raw.githubusercontent.com/trenoncourt/AutoQueryable/master/LICENSE</PackageLicenseUrl>
<Authors>Thibaut Renoncourt</Authors>
<Product>AutoQueryable</Product>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</Description>
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</AssemblyTitle>
<Version>2.0.3-beta</Version>
<Version>2.0.4-beta</Version>
<Authors>Thibaut Renoncourt</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>AutoQueryable.AspNetCore.Filter</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>AutoQueryable.AspNetCore.Swagger add Swagger parameters for AutoQueryable to Asp.Net Core.</Description>
<AssemblyTitle>AutoQueryable.AspNetCore.Swagger add Swagger parameters for AutoQueryable to Asp.Net Core.</AssemblyTitle>
<Version>2.0.3-beta</Version>
<Version>2.0.4-beta</Version>
<Authors>Thibaut Renoncourt</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>AutoQueryable.AspNetCore.Swagger</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<Version>2.0.3-beta</Version>
<Version>2.0.4-beta</Version>
<Authors>Thibaut Renoncourt</Authors>
<Company>-</Company>
<Product>AutoQueryable</Product>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>2.0.3-beta</Version>
<Version>2.0.4-beta</Version>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.1</LangVersion>
<Product>AutoQueryable</Product>
Expand Down
2 changes: 1 addition & 1 deletion src/AutoQueryable/AutoQueryable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>AutoQueryable add auto querying functionality like OData with best url practices to Asp.Net Core.</Description>
<AssemblyTitle>AutoQueryable add auto querying functionality like OData with best url practices to Asp.Net Core.</AssemblyTitle>
<Version>2.0.3-beta</Version>
<Version>2.0.4-beta</Version>
<Authors>Thibaut Renoncourt, Nils Goovaerts</Authors>
<TargetFramework>netstandard1.3</TargetFramework>
<AssemblyName>AutoQueryable</AssemblyName>
Expand Down
5 changes: 5 additions & 0 deletions src/AutoQueryable/Helpers/ConvertHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static dynamic Convert(string value, Type type, IFormatProvider formatPro
return Guid.Parse(value);
}

if (Equals(type.GetTypeInfo(), typeof(decimal).GetTypeInfo()))
{
return decimal.Parse(value, CultureInfo.InvariantCulture);
}

if (Equals(type.GetTypeInfo(), typeof(DateTime).GetTypeInfo()))
{
if (formatProvider != null)
Expand Down
2 changes: 1 addition & 1 deletion test/AutoQueryable.UnitTest/DataInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void InitializeSeed(AutoQueryableDbContext dbContext)
Color = i % 2 == 0 ? "red" : "black",
ProductCategory = i % 2 == 0 ? redCategory : blackCategory,
ProductModel = model1,
ListPrice = i,
ListPrice = (decimal) (i / 5.0),
Name = i % 2 == 0 ? null : $"Product {i}",
ProductNumber = Guid.NewGuid().ToString(),
Rowguid = Guid.Parse(GuidString),
Expand Down
14 changes: 14 additions & 0 deletions test/AutoQueryable.UnitTest/FilterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,5 +477,19 @@ public void DateYearShouldNotEqual2011()
query.Count().Should().Be(0);
}
}

[Fact]
public void FilterWithDecimalPoints_Query_ResultsCountShouldBeOne()
{
using (var context = new AutoQueryableDbContext())
{
_queryStringAccessor.SetQueryString("ListPrice=1.6");

DataInitializer.InitializeSeed(context);
var query = context.Product.AutoQueryable(_autoQueryableContext) as IQueryable<object>;

query.Count().Should().Be(1);
}
}
}
}

0 comments on commit dedf2fc

Please sign in to comment.