Skip to content

Commit 70aa5ee

Browse files
Fix issue #172 UserTypeConvention does not apply to nullable types
1 parent 4900f06 commit 70aa5ee

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/FluentNHibernate/Conventions/UserTypeConvention.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ public abstract class UserTypeConvention<TUserType> : IUserTypeConvention
1818
public virtual void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
1919
{
2020
var userType = Activator.CreateInstance<TUserType>();
21-
22-
criteria.Expect(x => x.Type == userType.ReturnedType);
21+
var returnedType = userType.ReturnedType;
22+
if (returnedType.IsValueType)
23+
{
24+
var nullableReturnedType = typeof(Nullable<>).MakeGenericType(returnedType);
25+
criteria.Expect(x => x.Type == returnedType || x.Type == nullableReturnedType);
26+
}
27+
else
28+
criteria.Expect(x => x.Type == returnedType);
2329
}
2430

2531
public virtual void Apply(IPropertyInstance instance)

0 commit comments

Comments
 (0)