Skip to content

Commit 1daf18a

Browse files
committed
Merge pull request #115 from tbushell/patch-2
Fix for issue #113
2 parents 23f67a3 + d01cf18 commit 1daf18a

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
@@ -205,9 +205,20 @@ public override void Configure(NHibernate.Cfg.Configuration configuration)
205205

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

213224
Add(new PassThroughMappingProvider(mapping));

0 commit comments

Comments
 (0)