1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Linq ;
3
4
using NHibernate . Engine ;
4
5
using NHibernate . SqlCommand ;
5
6
using NHibernate . Type ;
@@ -42,7 +43,12 @@ public abstract class Collection : IFetchable, IValue, IFilterable
42
43
private bool orphanDelete ;
43
44
private int batchSize = - 1 ;
44
45
private FetchMode fetchMode ;
46
+
47
+ private string collectionPersisterClassAssemblyQualifedName ;
48
+
49
+ [ NonSerialized ]
45
50
private System . Type collectionPersisterClass ;
51
+
46
52
private string referencedPropertyName ;
47
53
private string typeName ;
48
54
@@ -65,7 +71,12 @@ public abstract class Collection : IFetchable, IValue, IFilterable
65
71
private ExecuteUpdateResultCheckStyle deleteAllCheckStyle ;
66
72
67
73
private bool isGeneric ;
74
+
75
+ private string [ ] genericArgumentsAssemblyQualifiedNames ;
76
+
77
+ [ NonSerialized ]
68
78
private System . Type [ ] genericArguments ;
79
+
69
80
private readonly Dictionary < string , string > filters = new Dictionary < string , string > ( ) ;
70
81
private readonly Dictionary < string , string > manyToManyFilters = new Dictionary < string , string > ( ) ;
71
82
private bool subselectLoadable ;
@@ -138,8 +149,16 @@ public PersistentClass Owner
138
149
139
150
public System . Type CollectionPersisterClass
140
151
{
141
- get { return collectionPersisterClass ; }
142
- set { collectionPersisterClass = value ; }
152
+ get
153
+ {
154
+ if ( collectionPersisterClass != null || collectionPersisterClassAssemblyQualifedName == null ) return collectionPersisterClass ;
155
+ return ( collectionPersisterClass = ReflectHelper . ClassForName ( collectionPersisterClassAssemblyQualifedName ) ) ;
156
+ }
157
+ set
158
+ {
159
+ collectionPersisterClass = value ;
160
+ collectionPersisterClassAssemblyQualifedName = value ? . AssemblyQualifiedName ;
161
+ }
143
162
}
144
163
145
164
// The type of this property is object, so as to accommodate
@@ -323,18 +342,26 @@ public bool IsGeneric
323
342
/// </summary>
324
343
public System . Type [ ] GenericArguments
325
344
{
326
- get { return genericArguments ; }
327
- set { genericArguments = value ; }
345
+ get
346
+ {
347
+ if ( genericArguments != null || genericArgumentsAssemblyQualifiedNames == null ) return genericArguments ;
348
+ return ( genericArguments = genericArgumentsAssemblyQualifiedNames . Select ( ReflectHelper . ClassForName ) . ToArray ( ) ) ;
349
+ }
350
+ set
351
+ {
352
+ genericArguments = value ;
353
+ genericArgumentsAssemblyQualifiedNames = value ? . Select ( x => x . AssemblyQualifiedName ) . ToArray ( ) ;
354
+ }
328
355
}
329
356
330
357
protected void CheckGenericArgumentsLength ( int expectedLength )
331
358
{
332
- if ( genericArguments . Length != expectedLength )
359
+ if ( GenericArguments . Length != expectedLength )
333
360
{
334
361
throw new MappingException (
335
362
string . Format (
336
363
"Error mapping generic collection {0}: expected {1} generic parameters, but the property type has {2}" ,
337
- Role , expectedLength , genericArguments . Length ) ) ;
364
+ Role , expectedLength , GenericArguments . Length ) ) ;
338
365
}
339
366
}
340
367
0 commit comments