Skip to content

Commit b8c0869

Browse files
committed
applied changes. 1 MSpec test broken
1 parent 4900f06 commit b8c0869

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@ public void MixedKeyPropertyAndManyToOneOrdering()
160160
.HasName("key-property");
161161
}
162162

163+
[Test]
164+
public void CompositeIdWithSubclass()
165+
{
166+
new MappingTester<CompIdTarget>()
167+
.SubClassMapping<ComIdSubclass>(s =>
168+
{
169+
s.Table("subclasstable");
170+
s.KeyColumn("subclass_longId");
171+
s.KeyColumn("subclass_nullablelongId");
172+
})
173+
.ForMapping(c => c.CompositeId()
174+
.KeyProperty(x => x.LongId)
175+
.KeyProperty(x => x.NullableLongId))
176+
.Element("class/joined-subclass/key/*[1]")
177+
.Exists().HasName("column").HasAttribute("name", "subclass_longId")
178+
.RootElement.Element("class/joined-subclass/key/*[2]")
179+
.Exists().HasName("column").HasAttribute("name", "subclass_nullablelongId");
180+
}
181+
163182
public class CompIdTarget
164183
{
165184
public virtual long LongId { get; set; }
@@ -170,6 +189,11 @@ public class CompIdTarget
170189
public virtual SomeEnum EnumProperty { get; set; }
171190
}
172191

192+
public class ComIdSubclass : CompIdTarget
193+
{
194+
195+
}
196+
173197
public enum SomeEnum
174198
{}
175199

src/FluentNHibernate/MappingModel/Collections/AttributeLayeredValues.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Runtime.Serialization;
45

56
namespace FluentNHibernate.MappingModel.Collections
67
{
78
[Serializable]
8-
public class AttributeLayeredValues
9+
public class AttributeLayeredValues: ISerializable
910
{
10-
readonly Dictionary<string, LayeredValues> inner = new Dictionary<string, LayeredValues>();
11+
readonly Dictionary<string, LayeredValues> inner;
12+
13+
public AttributeLayeredValues()
14+
{
15+
inner = new Dictionary<string, LayeredValues>();
16+
}
17+
18+
19+
public AttributeLayeredValues(SerializationInfo info, StreamingContext context)
20+
{
21+
inner = (Dictionary<string, LayeredValues>)info
22+
.GetValue("inner", typeof(Dictionary<string, LayeredValues>));
23+
inner.OnDeserialization(this);
24+
}
1125

1226
public LayeredValues this[string attribute]
1327
{
@@ -83,12 +97,16 @@ public override int GetHashCode()
8397

8498
pairCode += pair.Key.GetHashCode();
8599
pairCode += pair.Value.GetHashCode();
86-
87100
hashCode += pairCode ^ 367;
88101
}
89102
}
90103

91104
return hashCode;
92105
}
106+
107+
public void GetObjectData(SerializationInfo info, StreamingContext context)
108+
{
109+
info.AddValue("inner", inner);
110+
}
93111
}
94112
}

0 commit comments

Comments
 (0)