| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
TypeHandlers\Int32TypeHandler.cs | 50.0 % | 70.0 % | 80.0 % | 68.4 % |
|
1 | ||
2 | #region Apache Notice | |
3 | /***************************************************************************** | |
4 | * $Header: $ | |
5 | * $Revision: $ | |
6 | * $Date: $ | |
7 | * | |
8 | * iBATIS.NET Data Mapper | |
9 | * Copyright (C) 2004 - Gilles Bayon | |
10 | * | |
11 | * | |
12 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
13 | * you may not use this file except in compliance with the License. | |
14 | * You may obtain a copy of the License at | |
15 | * | |
16 | * http://www.apache.org/licenses/LICENSE-2.0 | |
17 | * | |
18 | * Unless required by applicable law or agreed to in writing, software | |
19 | * distributed under the License is distributed on an "AS IS" BASIS, | |
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
21 | * See the License for the specific language governing permissions and | |
22 | * limitations under the License. | |
23 | * | |
24 | ********************************************************************************/ | |
25 | #endregion | |
26 | ||
27 | #region Using | |
28 | ||
29 | using System; | |
30 | using System.Data; | |
31 | using IBatisNet.DataMapper.Configuration.ParameterMapping; | |
32 | using IBatisNet.DataMapper.Configuration.ResultMapping; | |
33 | #endregion | |
34 | ||
35 | ||
36 | namespace IBatisNet.DataMapper.TypeHandlers | |
37 | { | |
38 | /// <summary> | |
39 | /// Summary description for Int32TypeHandler. | |
40 | /// </summary> | |
41 | internal class Int32TypeHandler : BaseTypeHandler | |
42 | { | |
43 | ||
44 | /// <summary> | |
45 | /// | |
46 | /// </summary> | |
47 | /// <param name="mapping"></param> | |
48 | /// <param name="dataReader"></param> | |
49 | /// <returns></returns> | |
50 | 366 | public override object GetValueByName(ResultProperty mapping, IDataReader dataReader) |
51 | { | |
52 | 366 | int index = dataReader.GetOrdinal(mapping.ColumnName); |
53 | ||
54 | 366 | if (dataReader.IsDBNull(index) == true) |
55 | { | |
56 | 0 | return DBNull.Value; |
57 | } | |
58 | else | |
59 | { | |
60 | // Don't used dataReader.GetInt32 to fix oracle who alwray return decimal type | |
61 | 366 | return Convert.ToInt32(dataReader.GetValue(index)); |
62 | } | |
63 | } | |
64 | ||
65 | 43 | public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) |
66 | { | |
67 | 43 | if (dataReader.IsDBNull(mapping.ColumnIndex) == true) |
68 | { | |
69 | 0 | return DBNull.Value; |
70 | } | |
71 | else | |
72 | { | |
73 | // Don't used dataReader.GetInt32 to fix oracle who alwray return decimal type | |
74 | 43 | return Convert.ToInt32(dataReader.GetValue(mapping.ColumnIndex)); |
75 | } | |
76 | } | |
77 | ||
78 | 8 | public override object GetDataBaseValue(object outputValue, Type parameterType ) |
79 | { | |
80 | 8 | return Convert.ToInt32(outputValue); |
81 | } | |
82 | ||
83 | 0 | public override object ValueOf(Type type, string s) |
84 | { | |
85 | return Convert.ToInt32(s); | |
86 | } | |
87 | ||
88 | ||
89 | public override bool IsSimpleType | |
90 | { | |
91 | 21 | get |
92 | { | |
93 | 21 | return true; |
94 | } | |
95 | } | |
96 | ||
97 | } | |
98 | } | |
99 |
|