Drop this one too
[mono.git] / mcs / class / Mono.Data.SqliteClient / Mono.Data.SqliteClient / SqliteParameter.cs
1 //
2 // Mono.Data.SqliteClient.SqliteParameter.cs
3 //
4 // Represents a parameter to a SqliteCommand, and optionally, its mapping to 
5 // DataSet columns.
6 //
7 // Author(s): Vladimir Vukicevic  <vladimir@pobox.com>
8 //            Everaldo Canuto  <everaldo_canuto@yahoo.com.br>
9 //
10 // Copyright (C) 2002  Vladimir Vukicevic
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using System;
33 using System.Data;
34 #if NET_2_0
35 using System.Data.Common;
36 #endif
37
38 namespace Mono.Data.SqliteClient
39 {
40         public class SqliteParameter :
41 #if NET_2_0
42                 DbParameter
43 #else
44                 IDbDataParameter
45 #endif
46         {
47
48                 #region Fields
49                 
50                 private string name;
51                 private DbType type;
52                 private DbType originalType;
53                 private bool typeSet;
54                 private string source_column;
55                 private ParameterDirection direction;
56                 private DataRowVersion row_version;
57                 private object param_value;
58                 private byte precision;
59                 private byte scale;
60                 private int size;
61                 private bool isNullable;
62                 private bool sourceColumnNullMapping;
63                 
64                 #endregion
65
66                 #region Constructors and destructors
67                 
68                 public SqliteParameter ()
69                 {
70                         type = DbType.String;
71                         direction = ParameterDirection.Input;
72                         isNullable = true;
73                 }
74                 
75                 public SqliteParameter (string name, DbType type)
76                 {
77                         this.name = name;
78                         this.type = type;
79                         isNullable = true;
80                 }
81                 
82                 public SqliteParameter (string name, object value)
83                 {
84                         this.name = name;
85                         type = DbType.String;
86                         param_value = value;
87                         direction = ParameterDirection.Input;
88                         isNullable = true;
89                 }
90                 
91                 public SqliteParameter (string name, DbType type, int size) : this (name, type)
92                 {
93                         this.size = size;
94                 }
95                 
96                 public SqliteParameter (string name, DbType type, int size, string src_column) : this (name ,type, size)
97                 {
98                         source_column = src_column;
99                 }
100                 
101                 #endregion
102
103                 #region Properties
104                 
105 #if NET_2_0
106                 override
107 #endif
108                 public DbType DbType {
109                         get { return type; }
110                         set {
111                                 if (!typeSet) {
112                                         originalType = type;
113                                         typeSet = true;
114                                 }
115                                 type = value;
116                                 if (!typeSet)
117                                         originalType = type;
118                         }
119                 }
120         
121 #if NET_2_0
122                 override
123 #endif
124                 public ParameterDirection Direction {
125                         get { return direction; }
126                         set { direction = value; }
127                 }
128         
129 #if NET_2_0
130                 override
131 #endif
132                 public bool IsNullable {
133                         get { return isNullable; }
134 #if NET_2_0
135                         set { isNullable = value; }
136 #endif
137                 }
138
139 #if NET_2_0
140                 override
141 #endif
142                 public string ParameterName {
143                         get { return name; }
144                         set { name = value; }
145                 }
146         
147                 public byte Precision {
148                         get { return precision; }
149                         set { precision = value; }
150                 }
151                 
152                 public byte Scale {
153                         get { return scale; }
154                         set { scale = value; }
155                 }
156
157 #if NET_2_0
158                 override
159 #endif
160                 public int Size {
161                         get { return size; }
162                         set { size = value; }
163                 }
164                 
165 #if NET_2_0
166                 override
167 #endif
168                 public string SourceColumn {
169                         get { return source_column; }
170                         set { source_column = value; }
171                 }
172
173 #if NET_2_0
174                 public override bool SourceColumnNullMapping {
175                         get { return sourceColumnNullMapping; }
176                         set { sourceColumnNullMapping = value; }
177                 }
178 #endif
179
180 #if NET_2_0
181                 override
182 #endif
183                 public DataRowVersion SourceVersion {
184                         get { return row_version; }
185                         set { row_version = value; }
186                 }
187                 
188 #if NET_2_0
189                 override
190 #endif
191                 public object Value {
192                         get { return param_value; }
193                         set { param_value = value; }
194                 }
195                 
196                 #endregion
197
198                 #region methods
199 #if NET_2_0
200                 public override void ResetDbType ()
201                 {
202                         type = originalType;
203                 }
204 #endif
205                 #endregion
206         }
207 }