fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

TypeReference.IsNullable false for nullable enum

Open SYoungPB opened this issue 9 years ago • 0 comments

I am writing a simple IPropertyConvention to map certain property types to Not.Nullable(). When I have a nullable enum property IPropertyInstance.Type.IsNullable returns false.

Here is my sample code:

public class NotNullPropertyConvention : IPropertyConvention {
    public void Apply(IPropertyInstance instance) {
        if (instance.Type.GetUnderlyingSystemType().IsPrimitive ||
            (instance.Type.IsEnum && !instance.Type.IsNullable) ||
            (instance.Type == typeof(DateTime)) ||
            (instance.Type == typeof(Guid))) {
            instance.Not.Nullable();
        }
    }
}

SYoungPB avatar Jul 25 '16 07:07 SYoungPB