wasCSharpSQLite – Blame information for rev 2

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 //
2 // Community.CsharpSqlite.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 using System.Data.Common;
35  
36 namespace Community.CsharpSqlite.SQLiteClient
37 {
38 public class SqliteParameter : DbParameter
39 {
40  
41 #region Fields
42  
43 private string name;
44 private DbType type;
45 private DbType originalType;
46 private bool typeSet;
47 private string source_column;
48 private ParameterDirection direction;
49 #if !SQLITE_SILVERLIGHT
50 private DataRowVersion row_version;
51 #endif
52 private object param_value;
53 private byte precision;
54 private byte scale;
55 private int size;
56 private bool isNullable;
57 private bool sourceColumnNullMapping;
58  
59 #endregion
60  
61 #region Constructors and destructors
62  
63 public SqliteParameter ()
64 {
65 type = DbType.String;
66 direction = ParameterDirection.Input;
67 isNullable = true;
68 }
69  
70 public SqliteParameter (string name, DbType type)
71 {
72 this.name = name;
73 this.type = type;
74 isNullable = true;
75 }
76  
77 public SqliteParameter (string name, object value)
78 {
79 this.name = name;
80 type = DbType.String;
81 param_value = value;
82 direction = ParameterDirection.Input;
83 isNullable = true;
84 }
85  
86 public SqliteParameter (string name, DbType type, int size) : this (name, type)
87 {
88 this.size = size;
89 }
90  
91 public SqliteParameter (string name, DbType type, int size, string src_column) : this (name ,type, size)
92 {
93 source_column = src_column;
94 }
95  
96 #endregion
97  
98 #region Properties
99  
100 public override DbType DbType {
101 get { return type; }
102 set {
103 if (!typeSet) {
104 originalType = type;
105 typeSet = true;
106 }
107 type = value;
108 if (!typeSet)
109 originalType = type;
110 }
111 }
112  
113 public override ParameterDirection Direction {
114 get { return direction; }
115 set { direction = value; }
116 }
117  
118 public override bool IsNullable {
119 get { return isNullable; }
120 set { isNullable = value; }
121 }
122  
123 public override string ParameterName {
124 get { return name; }
125 set { name = value; }
126 }
127  
2 office 128 public override byte Precision {
1 office 129 get { return precision; }
130 set { precision = value; }
131 }
132  
2 office 133 public override byte Scale {
1 office 134 get { return scale; }
135 set { scale = value; }
136 }
137  
138 public override int Size {
139 get { return size; }
140 set { size = value; }
141 }
142  
143 public override string SourceColumn {
144 get { return source_column; }
145 set { source_column = value; }
146 }
147  
148 public override bool SourceColumnNullMapping {
149 get { return sourceColumnNullMapping; }
150 set { sourceColumnNullMapping = value; }
151 }
152 #if !SQLITE_SILVERLIGHT
153 public override DataRowVersion SourceVersion {
154 get { return row_version; }
155 set { row_version = value; }
156 }
157 #endif
158 public override object Value {
159 get { return param_value; }
160 set { param_value = value; }
161 }
162  
163 #endregion
164  
165 #region methods
166  
167 public override void ResetDbType ()
168 {
169 type = originalType;
170 }
171  
172 #endregion
173 }
174 }