henkmollema / Dapper-FluentMap

Provides a simple API to fluently map POCO properties to database columns when using Dapper.
MIT License
429 stars 88 forks source link

Map Nullable property using convention #82

Closed jrshu closed 5 years ago

jrshu commented 5 years ago

When I use the Convention.Properties<T> method to define a convention for a nullable type, it strips the nullable part and uses the underlying type instead:

var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T);

This causes the properties of any nullable types not to be properly mapped. Is there any reason why you don't want to use the nullable type directly? And is there an alternative preferred way to map nullable properties?

Thanks!

henkmollema commented 5 years ago

This is a bug. I meant to normalize the property types to non-nullables so that when you define a convention for int properties it is also applied to int? properties. However, I did not resolve the underlying type for the property types themself which causes this mismatch.

I'll change the behavior to the following: