fluent-nhibernate
fluent-nhibernate copied to clipboard
TypeReference.IsNullable false for nullable enum
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();
}
}
}