-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathMap.cs
92 lines (86 loc) · 2.33 KB
/
Map.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections;
using NHibernate.Type;
namespace NHibernate.Mapping
{
/// <summary>
/// A map has a primary key consisting of the key columns
/// + index columns.
/// </summary>
[Serializable]
public class Map : IndexedCollection
{
/// <summary>
/// Initializes a new instance of the <see cref="Map" /> class.
/// </summary>
/// <param name="owner">The <see cref="PersistentClass"/> that contains this map mapping.</param>
public Map(PersistentClass owner) : base(owner)
{
}
public override bool IsMap
{
get { return true; }
}
public override CollectionType CollectionType
{
get
{
if (IsGeneric && IsSorted)
{
CheckGenericArgumentsLength(2);
if (TypeName != null && TypeName.Contains("sorted-list"))
{
return
TypeFactory.GenericSortedList(Role, ReferencedPropertyName, Comparer, GenericArguments[0], GenericArguments[1]);
}
else if (TypeName != null && TypeName.Contains("sorted-dictionary"))
{
return
TypeFactory.GenericSortedDictionary(Role, ReferencedPropertyName, Comparer, GenericArguments[0],
GenericArguments[1]);
}
else
{
throw new MappingException(
"Use collection-type='sorted-list/sorted-dictionary' to choose implementation for generic map owned by " + this.OwnerEntityName);
}
}
return base.CollectionType;
}
}
/// <summary>
/// Gets the appropriate <see cref="CollectionType"/> that is
/// specialized for this list mapping.
/// </summary>
public override CollectionType DefaultCollectionType
{
get
{
if (IsGeneric)
{
if (HasOrder)
{
throw new MappingException(
"Cannot use order-by with generic map, no appropriate collection implementation is available");
}
else if (IsSorted)
{
throw new AssertionFailure("Error in NH: should not get here (Mapping.Map.DefaultCollectionType)");
}
else
{
CheckGenericArgumentsLength(2);
return TypeFactory.GenericMap(Role, ReferencedPropertyName, GenericArguments[0], GenericArguments[1]);
}
}
throw new MappingException("Non-generic persistent maps are not supported (role " + Role + ").");
}
}
public override void CreateAllKeys()
{
base.CreateAllKeys();
if (!IsInverse)
Index.CreateForeignKey();
}
}
}