Skip to content

Commit 8ddda12

Browse files
committed
Merge remote-tracking branch 'legenden/master'
2 parents e7cf411 + 50c58a6 commit 8ddda12

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/FluentNHibernate.Testing/DomainModel/Mapping/AnyPartTester.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,27 @@ public void AnyIsAfterIdElement()
173173

174174
mapTest.Element("class/id").ShouldBeInParentAtPosition(0);
175175
}
176+
177+
178+
[Test]
179+
public void SpecificMetaTypeShouldNotClearMetaValues()
180+
{
181+
var mapTest = new MappingTester<MappedObject>()
182+
.ForMapping(map =>
183+
{
184+
map.Id(x => x.Id);
185+
map.ReferencesAny(x => x.Parent)
186+
.EntityIdentifierColumn("AnyId")
187+
.EntityTypeColumn("AnyType")
188+
.IdentityType(x => x.Id)
189+
.MetaType<int>()
190+
.AddMetaValue<SecondMappedObject>("1");
191+
});
192+
193+
mapTest
194+
.Element("class/any/meta-value")
195+
.HasAttribute("value", "1")
196+
.HasAttribute("class", typeof(SecondMappedObject).AssemblyQualifiedName);
197+
}
176198
}
177199
}

src/FluentNHibernate/Mapping/AnyPart.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,10 @@ AnyMapping IAnyMappingProvider.GetAnyMapping()
156156
if (!mapping.IsSpecified("Name"))
157157
mapping.Name = property.Name;
158158

159+
metaValues.Each(mapping.AddMetaValue);
159160
if (!mapping.IsSpecified("MetaType"))
160161
{
161-
if (metaValues.Count() > 0)
162-
{
163-
metaValues.Each(mapping.AddMetaValue);
164-
mapping.MetaType = new TypeReference(typeof(string));
165-
}
166-
else
167-
mapping.MetaType = new TypeReference(property.PropertyType);
162+
mapping.MetaType = metaValues.Count() > 0 ? new TypeReference(typeof(string)) : new TypeReference(property.PropertyType);
168163
}
169164

170165
foreach (var column in typeColumns)

0 commit comments

Comments
 (0)