Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Map Nullable property using convention #82

Closed
jrshu opened this issue Dec 15, 2018 · 1 comment
Closed

Map Nullable property using convention #82

jrshu opened this issue Dec 15, 2018 · 1 comment
Labels
Milestone

Comments

@jrshu
Copy link

jrshu commented Dec 15, 2018

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 henkmollema added this to the v1.8 milestone Mar 28, 2019
@henkmollema
Copy link
Owner

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:

  • When defining a convention for int (e.g. Properties<int>) it will be applied to properties of type int as well as type int?.
  • When explicitly defining a convention for a nullable type (e.g. Properties<int?>) it will only be applied to properties of type int? and not to the non-nullable type int.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants