Skip to content

Commit d01cf18

Browse files
committed
Fix for issue #113
1 parent dbbdb3f commit d01cf18

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/FluentNHibernate/Automapping/AutoPersistenceModel.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,20 @@ public override void Configure(NHibernate.Cfg.Configuration configuration)
203203

204204
private void AddMapping(Type type)
205205
{
206-
log.BeginAutomappingType(type);
207-
208206
Type typeToMap = GetTypeToMap(type);
207+
208+
// Fixes https://github.com/jagregory/fluent-nhibernate/issues/113,
209+
// where 'type' would not be mapped if 'GetTypeToMap' returned the
210+
// base type
211+
if (typeToMap != type)
212+
{
213+
log.BeginAutomappingType(type);
214+
var derivedMapping = autoMapper.Map(type, mappingTypes);
215+
216+
Add(new PassThroughMappingProvider(derivedMapping));
217+
}
218+
219+
log.BeginAutomappingType(typeToMap);
209220
var mapping = autoMapper.Map(typeToMap, mappingTypes);
210221

211222
Add(new PassThroughMappingProvider(mapping));

0 commit comments

Comments
 (0)