Skip to content

Commit

Permalink
Merge pull request #56 from seesharper/quick-fix-propertyvalidator
Browse files Browse the repository at this point in the history
User underlying type when validating nullable properties
  • Loading branch information
seesharper committed Mar 29, 2022
2 parents 2de6ae1 + e653697 commit a6041a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ variables:
- group: api-keys

pool:
name: Hosted Ubuntu 1604
vmImage: 'ubuntu-latest'
steps:
- bash: 'sudo apt install nuget'
displayName: 'Install NuGet'
- bash: |
curl -L https://github.com/filipw/dotnet-script/releases/download/0.28.0/dotnet-script.0.28.0.zip > dotnet-script.zip
curl -L https://github.com/filipw/dotnet-script/releases/download/1.3.1/dotnet-script.1.3.1.zip > dotnet-script.zip
unzip -o dotnet-script.zip -d ./
displayName: 'Install latest otnet-script'

Expand Down
4 changes: 2 additions & 2 deletions src/DbReader/DbReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../mono.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netstandard2.0;net462</TargetFrameworks>
<Version>2.5.0</Version>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net462</TargetFrameworks>
<Version>2.5.1</Version>
<Authors>Bernhard Richter</Authors>
<PackageProjectUrl>https://github.com/seesharper/DbReader</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
Expand Down
6 changes: 1 addition & 5 deletions src/DbReader/Mapping/PropertyTypeValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,10 @@ public MappingInfo[] Execute(Type type, IDataRecord dataRecord, string prefix)
}

var propertyType = mappingInfo.Property.PropertyType;
// if (propertyType.IsEnum)
// {
// propertyType = propertyType.GetUnderlyingType();
// }

if (!propertyType.IsAssignableFrom(mappingInfo.ColumnInfo.Type.GetTypeInfo()) && !ValueConverter.CanConvert(propertyType))
{
if (propertyType.IsEnum)
if (propertyType.IsEnum || propertyType.IsNullable())
{
Execute(propertyType.GetUnderlyingType(), dataRecord, prefix);
}
Expand Down

0 comments on commit a6041a8

Please sign in to comment.