1
|
|
|
2
|
|
#region Apache Notice
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
|
|
19
|
|
|
20
|
|
|
21
|
|
|
22
|
|
|
23
|
|
|
24
|
|
|
25
|
|
#endregion
|
26
|
|
|
27
|
|
#region Using
|
28
|
|
|
29
|
|
using System;
|
30
|
|
using System.Data;
|
31
|
|
using System.Globalization;
|
32
|
|
|
33
|
|
using IBatisNet.DataMapper.Configuration.ResultMapping;
|
34
|
|
#endregion
|
35
|
|
|
36
|
|
|
37
|
|
|
38
|
|
namespace IBatisNet.DataMapper.TypeHandlers
|
39
|
|
{
|
40
|
|
|
41
|
|
|
42
|
|
|
43
|
|
internal class GuidTypeHandler : BaseTypeHandler
|
44
|
|
{
|
45
|
|
|
46
|
|
|
47
|
|
|
48
|
|
|
49
|
|
|
50
|
|
|
51
|
11
|
public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
|
52
|
|
{
|
53
|
11
|
int index = dataReader.GetOrdinal(mapping.ColumnName);
|
54
|
|
|
55
|
11
|
if (dataReader.IsDBNull(index) == true)
|
56
|
|
{
|
57
|
1
|
return System.DBNull.Value;
|
58
|
|
}
|
59
|
|
else
|
60
|
|
{
|
61
|
10
|
return new Guid(dataReader.GetGuid(index).ToString());
|
62
|
|
}
|
63
|
|
}
|
64
|
|
|
65
|
1
|
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
|
66
|
|
{
|
67
|
1
|
if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
|
68
|
|
{
|
69
|
0
|
return System.DBNull.Value;
|
70
|
|
}
|
71
|
|
else
|
72
|
|
{
|
73
|
1
|
return new Guid(dataReader.GetValue(mapping.ColumnIndex).ToString());
|
74
|
|
}
|
75
|
|
}
|
76
|
|
|
77
|
1
|
public override object ValueOf(Type type, string s)
|
78
|
|
{
|
79
|
1
|
return new Guid(s);
|
80
|
|
}
|
81
|
|
|
82
|
0
|
public override object GetDataBaseValue(object outputValue, Type parameterType )
|
83
|
|
{
|
84
|
|
return new Guid(outputValue.ToString());
|
85
|
|
}
|
86
|
|
|
87
|
|
|
88
|
|
public override bool IsSimpleType
|
89
|
|
{
|
90
|
1
|
get
|
91
|
|
{
|
92
|
1
|
return true;
|
93
|
|
}
|
94
|
|
}
|
95
|
|
}
|
96
|
|
}
|
97
|
|
|