forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToOne.cs
88 lines (76 loc) · 1.92 KB
/
ToOne.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
using System;
using NHibernate.Type;
using NHibernate.Util;
namespace NHibernate.Mapping
{
/// <summary>
/// A simple-point association (ie. a reference to another entity).
/// </summary>
[Serializable]
public abstract class ToOne : SimpleValue, IFetchable
{
private FetchMode fetchMode;
private bool lazy = true;
internal string referencedPropertyName;
private string referencedEntityName;
private bool unwrapProxy;
/// <summary>
///
/// </summary>
public ToOne(Table table) : base(table)
{
}
/// <summary></summary>
public override FetchMode FetchMode
{
get { return fetchMode; }
set { fetchMode = value; }
}
/// <summary></summary>
public string ReferencedPropertyName
{
get { return referencedPropertyName; }
set { referencedPropertyName = StringHelper.InternedIfPossible(value); }
}
public string ReferencedEntityName
{
get { return referencedEntityName; }
set { referencedEntityName = StringHelper.InternedIfPossible(value); }
}
public bool IsLazy
{
get { return lazy; }
set { lazy = value; }
}
/// <summary>
///
/// </summary>
public abstract override void CreateForeignKey();
public override void SetTypeUsingReflection(string className, string propertyName, string accesorName)
{
if (referencedEntityName == null)
{
System.Type refType = ReflectHelper.ReflectedPropertyClass(className, propertyName, accesorName);
referencedEntityName = refType.FullName;
}
}
public override bool IsValid(Engine.IMapping mapping)
{
if (referencedEntityName == null)
{
throw new MappingException("association must specify the referenced entity");
}
return base.IsValid(mapping);
}
public override abstract IType Type { get; }
public override bool IsTypeSpecified
{
get { return referencedEntityName != null; }
}
public bool UnwrapProxy
{
get { return unwrapProxy; }
set { unwrapProxy = value; }
}
}
}