1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Reflection;
|
21
|
|
using Seasar.Extension.ADO;
|
22
|
|
using Seasar.Extension.ADO.Impl;
|
23
|
|
|
24
|
|
namespace Seasar.Dao.Impl
|
25
|
|
{
|
26
|
|
public class RelationPropertyTypeImpl
|
27
|
|
: PropertyTypeImpl, IRelationPropertyType
|
28
|
|
{
|
29
|
|
protected int relationNo;
|
30
|
|
protected string[] myKeys;
|
31
|
|
protected string[] yourKeys;
|
32
|
|
protected IBeanMetaData beanMetaData;
|
33
|
|
|
34
|
0
|
public RelationPropertyTypeImpl(PropertyInfo propertyInfo)
|
35
|
|
: base(propertyInfo)
|
36
|
|
{
|
37
|
|
}
|
38
|
|
|
39
|
15
|
public RelationPropertyTypeImpl(PropertyInfo propertyInfo, int relationNo,
|
40
|
|
string[] myKeys, string[] yourKeys, IDatabaseMetaData dbMetaData, IDbms dbms)
|
41
|
|
: base(propertyInfo)
|
42
|
|
{
|
43
|
15
|
this.relationNo = relationNo;
|
44
|
15
|
this.myKeys = myKeys;
|
45
|
15
|
this.yourKeys = yourKeys;
|
46
|
15
|
Type beanType = propertyInfo.PropertyType;
|
47
|
15
|
beanMetaData = new BeanMetaDataImpl(beanType, dbMetaData, dbms);
|
48
|
|
}
|
49
|
|
|
50
|
|
#region IRelationPropertyType メンバ
|
51
|
|
|
52
|
|
public int RelationNo
|
53
|
|
{
|
54
|
153
|
get
|
55
|
|
{
|
56
|
153
|
return relationNo;
|
57
|
|
}
|
58
|
|
}
|
59
|
|
|
60
|
|
public int KeySize
|
61
|
|
{
|
62
|
122
|
get
|
63
|
|
{
|
64
|
122
|
if(myKeys.Length > 0)
|
65
|
0
|
return myKeys.Length;
|
66
|
|
else
|
67
|
122
|
return beanMetaData.PrimaryKeySize;
|
68
|
|
}
|
69
|
|
}
|
70
|
|
|
71
|
61
|
public string GetMyKey(int index)
|
72
|
|
{
|
73
|
61
|
if(myKeys.Length > 0)
|
74
|
0
|
return myKeys[index];
|
75
|
|
else
|
76
|
61
|
return beanMetaData.GetPrimaryKey(index);
|
77
|
|
}
|
78
|
|
|
79
|
15
|
public string GetYourKey(int index)
|
80
|
|
{
|
81
|
15
|
if(yourKeys.Length > 0)
|
82
|
0
|
return yourKeys[index];
|
83
|
|
else
|
84
|
15
|
return beanMetaData.GetPrimaryKey(index);
|
85
|
|
}
|
86
|
|
|
87
|
0
|
public bool IsYourKey(string columnName)
|
88
|
|
{
|
89
|
|
for(int i = 0; i < KeySize; ++i)
|
90
|
|
{
|
91
|
|
if(string.Compare(columnName, GetYourKey(i), true) == 0)
|
92
|
|
return true;
|
93
|
|
}
|
94
|
|
return false;
|
95
|
|
}
|
96
|
|
|
97
|
|
public IBeanMetaData BeanMetaData
|
98
|
|
{
|
99
|
68
|
get
|
100
|
|
{
|
101
|
68
|
return beanMetaData;
|
102
|
|
}
|
103
|
|
}
|
104
|
|
|
105
|
|
#endregion
|
106
|
|
|
107
|
|
}
|
108
|
|
}
|
109
|
|
|