Skip to content

Commit ffa4938

Browse files
committed
Since AutoPersistenceModel can be inherited, we can't do reflection on GetType(), since it will return the derived class' type and not typeof(AutoPersistenceModel).
1 parent d42e1d0 commit ffa4938

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/FluentNHibernate/Automapping/AutoPersistenceModel.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,16 @@ public void Override(Type overrideType)
363363
if (x.GetType().IsAssignableFrom(autoMappingType))
364364
{
365365
var overrideInstance = Activator.CreateInstance(overrideType);
366-
GetType()
367-
.GetMethod("OverrideHelper", BindingFlags.NonPublic | BindingFlags.Instance)
368-
.MakeGenericMethod(entityType)
369-
.Invoke(this, new [] {x, overrideInstance});
366+
367+
MethodInfo overrideHelperMethod = typeof(AutoPersistenceModel)
368+
.GetMethod("OverrideHelper", BindingFlags.NonPublic | BindingFlags.Instance);
369+
370+
if (overrideHelperMethod != null)
371+
{
372+
overrideHelperMethod
373+
.MakeGenericMethod(entityType)
374+
.Invoke(this, new[] {x, overrideInstance});
375+
}
370376
}
371377
});
372378
}

0 commit comments

Comments
 (0)