File tree Expand file tree Collapse file tree 3 files changed +49
-5
lines changed
FluentNHibernate.Testing/DomainModel/Mapping
FluentNHibernate/MappingModel Expand file tree Collapse file tree 3 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,26 @@ public void MixedKeyPropertyAndManyToOneOrdering()
159
159
. RootElement . Element ( "class/composite-id/*[2]" )
160
160
. HasName ( "key-property" ) ;
161
161
}
162
+
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
+ }
162
182
163
183
public class CompIdTarget
164
184
{
@@ -183,5 +203,10 @@ public class ComponentKey
183
203
public virtual int KeyCol1 { get ; set ; }
184
204
public virtual int KeyCol2 { get ; set ; }
185
205
}
206
+
207
+ public class ComIdSubclass : CompIdTarget
208
+ {
209
+
210
+ }
186
211
}
187
212
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
+ using System . Runtime . Serialization ;
4
5
5
6
namespace FluentNHibernate . MappingModel . Collections
6
7
{
7
8
[ Serializable ]
8
- public class AttributeLayeredValues
9
+ public class AttributeLayeredValues : ISerializable
9
10
{
10
- readonly Dictionary < string , LayeredValues > inner = new Dictionary < string , LayeredValues > ( ) ;
11
+ readonly Dictionary < string , LayeredValues > inner ;
11
12
13
+ public AttributeLayeredValues ( )
14
+ {
15
+ inner = new Dictionary < string , LayeredValues > ( ) ;
16
+ }
17
+
18
+ public AttributeLayeredValues ( SerializationInfo info , StreamingContext context )
19
+ {
20
+ inner = ( Dictionary < string , LayeredValues > ) info
21
+ . GetValue ( "inner" , typeof ( Dictionary < string , LayeredValues > ) ) ;
22
+ inner . OnDeserialization ( this ) ;
23
+ }
24
+
12
25
public LayeredValues this [ string attribute ]
13
26
{
14
27
get
@@ -90,5 +103,10 @@ public override int GetHashCode()
90
103
91
104
return hashCode ;
92
105
}
106
+
107
+ public void GetObjectData ( SerializationInfo info , StreamingContext context )
108
+ {
109
+ info . AddValue ( "inner" , inner ) ;
110
+ }
93
111
}
94
112
}
Original file line number Diff line number Diff line change @@ -94,13 +94,14 @@ public ColumnMapping Clone()
94
94
95
95
public bool Equals ( ColumnMapping other )
96
96
{
97
- return Equals ( other . attributes , attributes ) && Equals ( other . Member , Member ) ;
97
+ return ( other != null ) &&
98
+ Equals ( other . attributes , attributes ) &&
99
+ Equals ( other . Member , Member ) ;
98
100
}
99
101
100
102
public override bool Equals ( object obj )
101
103
{
102
- if ( obj . GetType ( ) != typeof ( ColumnMapping ) ) return false ;
103
- return Equals ( ( ColumnMapping ) obj ) ;
104
+ return Equals ( obj as ColumnMapping ) ;
104
105
}
105
106
106
107
public override int GetHashCode ( )
You can’t perform that action at this time.
0 commit comments