forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOneToMany.cs
157 lines (131 loc) · 2.89 KB
/
OneToMany.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using System.Collections.Generic;
using NHibernate.Engine;
using NHibernate.Type;
namespace NHibernate.Mapping
{
/// <summary>
/// A mapping for a <c>one-to-many</c> association.
/// </summary>
[Serializable]
public class OneToMany : IValue
{
private string referencedEntityName;
private readonly Table referencingTable;
private PersistentClass associatedClass;
private bool ignoreNotFound;
public OneToMany(PersistentClass owner)
{
referencingTable = (owner == null) ? null : owner.Table;
}
private EntityType EntityType
{
get { return TypeFactory.ManyToOne(ReferencedEntityName, null, false, false, IsIgnoreNotFound, false, null); }
}
public bool IsIgnoreNotFound
{
get { return ignoreNotFound; }
set { ignoreNotFound = value; }
}
/// <summary></summary>
public IEnumerable<ISelectable> ColumnIterator
{
get { return associatedClass.Key.ColumnIterator; }
}
/// <summary></summary>
public int ColumnSpan
{
get { return associatedClass.Key.ColumnSpan; }
}
public string ReferencedEntityName
{
get { return referencedEntityName; }
set { referencedEntityName = value == null ? null : string.Intern(value); }
}
public Table ReferencingTable
{
get { return referencingTable; }
}
public IType Type
{
get { return EntityType; }
}
/// <summary></summary>
public PersistentClass AssociatedClass
{
get { return associatedClass; }
set { associatedClass = value; }
}
/// <summary></summary>
public Formula Formula
{
get { return null; }
}
/// <summary></summary>
public Table Table
{
get { return referencingTable; }
}
/// <summary></summary>
public bool IsNullable
{
get { return false; }
}
/// <summary></summary>
public bool IsSimpleValue
{
get { return false; }
}
public bool HasFormula
{
get { return false; }
}
/// <summary></summary>
public bool IsUnique
{
get { return false; }
}
/// <summary></summary>
public bool IsValid(IMapping mapping)
{
if (referencedEntityName == null)
{
throw new MappingException("one to many association must specify the referenced entity");
}
return true;
}
/// <summary></summary>
public FetchMode FetchMode
{
get { return FetchMode.Join; }
}
#region IValue Members
public bool IsAlternateUniqueKey
{
get { return false; }
}
public void SetTypeUsingReflection(string className, string propertyName, string accesorName)
{
}
public object Accept(IValueVisitor visitor)
{
return visitor.Accept(this);
}
#endregion
/// <summary>
///
/// </summary>
/// <remarks>No foreign key element for a one-to-many</remarks>
public void CreateForeignKey()
{
}
public bool[] ColumnInsertability
{
get { throw new InvalidOperationException(); }
}
public bool[] ColumnUpdateability
{
get { throw new InvalidOperationException(); }
}
}
}