|
From: <fab...@us...> - 2011-04-13 23:07:47
|
Revision: 5698
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5698&view=rev
Author: fabiomaulo
Date: 2011-04-13 23:07:40 +0000 (Wed, 13 Apr 2011)
Log Message:
-----------
Fixed issue when use event to map collection key
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs 2011-04-13 22:04:27 UTC (rev 5697)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs 2011-04-13 23:07:40 UTC (rev 5698)
@@ -1052,9 +1052,9 @@
ICollectionElementRelationMapper cert = DetermineCollectionElementRelationType(member, propertyPath, collectionElementType);
propertiesContainer.Bag(member, collectionPropertiesMapper =>
{
- InvokeBeforeMapBag(propertyPath, collectionPropertiesMapper);
cert.MapCollectionProperties(collectionPropertiesMapper);
- ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
+ InvokeBeforeMapBag(propertyPath, collectionPropertiesMapper);
+ ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
InvokeAfterMapBag(propertyPath, collectionPropertiesMapper);
}, cert.Map);
}
@@ -1066,9 +1066,9 @@
ICollectionElementRelationMapper cert = DetermineCollectionElementRelationType(member, propertyPath, collectionElementType);
propertiesContainer.List(member, collectionPropertiesMapper =>
{
- InvokeBeforeMapList(propertyPath, collectionPropertiesMapper);
cert.MapCollectionProperties(collectionPropertiesMapper);
- ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
+ InvokeBeforeMapList(propertyPath, collectionPropertiesMapper);
+ ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
InvokeAfterMapList(propertyPath, collectionPropertiesMapper);
}, cert.Map);
}
@@ -1089,9 +1089,9 @@
propertiesContainer.Map(member, collectionPropertiesMapper =>
{
- InvokeBeforeMapMap(propertyPath, collectionPropertiesMapper);
cert.MapCollectionProperties(collectionPropertiesMapper);
- ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
+ InvokeBeforeMapMap(propertyPath, collectionPropertiesMapper);
+ ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
InvokeAfterMapMap(propertyPath, collectionPropertiesMapper);
}, mkrm.Map, cert.Map);
}
@@ -1103,9 +1103,9 @@
ICollectionElementRelationMapper cert = DetermineCollectionElementRelationType(member, propertyPath, collectionElementType);
propertiesContainer.Set(member, collectionPropertiesMapper =>
{
- InvokeBeforeMapSet(propertyPath, collectionPropertiesMapper);
cert.MapCollectionProperties(collectionPropertiesMapper);
- ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
+ InvokeBeforeMapSet(propertyPath, collectionPropertiesMapper);
+ ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
InvokeAfterMapSet(propertyPath, collectionPropertiesMapper);
}, cert.Map);
}
@@ -1121,8 +1121,8 @@
}
propertiesContainer.IdBag(member, collectionPropertiesMapper =>
{
+ cert.MapCollectionProperties(collectionPropertiesMapper);
InvokeBeforeMapIdBag(propertyPath, collectionPropertiesMapper);
- cert.MapCollectionProperties(collectionPropertiesMapper);
ForEachMemberPath(member, propertyPath, pp => customizerHolder.InvokeCustomizers(pp, collectionPropertiesMapper));
InvokeAfterMapIdBag(propertyPath, collectionPropertiesMapper);
}, cert.Map);
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs 2011-04-13 22:04:27 UTC (rev 5697)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/MixAutomapping/BagCollectionTests.cs 2011-04-13 23:07:40 UTC (rev 5698)
@@ -1,5 +1,7 @@
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
+using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping.ByCode;
using NUnit.Framework;
using SharpTestsEx;
@@ -22,6 +24,17 @@
public string Simple { get; set; }
}
+ private class Parent
+ {
+ public int Id { get; set; }
+ public IEnumerable<Child> NickNames { get; set; }
+ }
+ private class Child
+ {
+ public int Id { get; set; }
+ public Parent AParent { get; set; }
+ }
+
[Test]
public void MatchWithEnumerableProperty()
{
@@ -71,5 +84,17 @@
inspector.IsBag(mi).Should().Be.False();
}
+
+ [Test]
+ public void WhenSetKeyThroughEventThenUseEvent()
+ {
+ var autoinspector = new SimpleModelInspector();
+ var mapper = new ModelMapper(autoinspector);
+ mapper.BeforeMapBag += (insp, prop, map) => map.Key(km => km.Column(prop.GetContainerEntity(insp).Name + "Id"));
+
+ var hbmMapping = mapper.CompileMappingFor(new[] {typeof(Parent)});
+ var hbmBag = hbmMapping.RootClasses[0].Properties.OfType<HbmBag>().Single();
+ hbmBag.Key.Columns.Single().name.Should().Be("ParentId");
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|