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