|
3 | 3 | using System.Collections.Generic; |
4 | 4 | using System.Data; |
5 | 5 | using System.Text; |
6 | | -using BaiRong.Core.Data.Helper; |
7 | 6 | using BaiRong.Core.Model.Enumerations; |
8 | 7 |
|
9 | 8 | namespace BaiRong.Core.Data |
10 | 9 | { |
11 | 10 | public class DataProviderBase |
12 | 11 | { |
13 | | - private AdoHelper _helper; |
14 | | - |
15 | | - private AdoHelper Helper |
16 | | - { |
17 | | - get |
18 | | - { |
19 | | - if (_helper != null) return _helper; |
20 | | - |
21 | | - if (WebConfigUtils.IsMySql) |
22 | | - { |
23 | | - _helper = new MySql(); |
24 | | - } |
25 | | - else |
26 | | - { |
27 | | - _helper = new SqlServer(); |
28 | | - } |
29 | | - return _helper; |
30 | | - } |
31 | | - } |
32 | | - |
33 | 12 | protected virtual string ConnectionString => WebConfigUtils.ConnectionString; |
34 | 13 |
|
35 | 14 | protected IDbConnection GetConnection() |
@@ -119,119 +98,119 @@ private static IDbDataParameter GetParameterInner(string parameterName, EDataTyp |
119 | 98 |
|
120 | 99 | protected IDataReader ExecuteReader(string commandText, params IDataParameter[] commandParameters) |
121 | 100 | { |
122 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText, commandParameters) : null; |
| 101 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText, commandParameters) : null; |
123 | 102 | } |
124 | 103 |
|
125 | 104 |
|
126 | 105 | protected IDataReader ExecuteReader(string commandText) |
127 | 106 | { |
128 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText) : null; |
| 107 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText) : null; |
129 | 108 | } |
130 | 109 |
|
131 | 110 |
|
132 | 111 | protected IDataReader ExecuteReader(IDbConnection conn, string commandText, params IDataParameter[] commandParameters) |
133 | 112 | { |
134 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(conn, CommandType.Text, commandText, commandParameters) : null; |
| 113 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(conn, CommandType.Text, commandText, commandParameters) : null; |
135 | 114 | } |
136 | 115 |
|
137 | 116 |
|
138 | 117 | protected IDataReader ExecuteReader(IDbConnection conn, string commandText) |
139 | 118 | { |
140 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(conn, CommandType.Text, commandText) : null; |
| 119 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(conn, CommandType.Text, commandText) : null; |
141 | 120 | } |
142 | 121 |
|
143 | 122 |
|
144 | 123 | protected IDataReader ExecuteReader(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters) |
145 | 124 | { |
146 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(trans, CommandType.Text, commandText, commandParameters) : null; |
| 125 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(trans, CommandType.Text, commandText, commandParameters) : null; |
147 | 126 | } |
148 | 127 |
|
149 | 128 |
|
150 | 129 | protected IDataReader ExecuteReader(IDbTransaction trans, string commandText) |
151 | 130 | { |
152 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(trans, CommandType.Text, commandText) : null; |
| 131 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(trans, CommandType.Text, commandText) : null; |
153 | 132 | } |
154 | 133 |
|
155 | 134 |
|
156 | 135 | protected IDataReader ExecuteReader(string connectionString, string commandText) |
157 | 136 | { |
158 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(connectionString, CommandType.Text, commandText) : null; |
| 137 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(connectionString, CommandType.Text, commandText) : null; |
159 | 138 | } |
160 | 139 |
|
161 | 140 | protected IDataReader ExecuteReader(string connectionString, string commandText, params IDataParameter[] commandParameters) |
162 | 141 | { |
163 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(connectionString, CommandType.Text, commandText, commandParameters) : null; |
| 142 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(connectionString, CommandType.Text, commandText, commandParameters) : null; |
164 | 143 | } |
165 | 144 |
|
166 | 145 |
|
167 | 146 | protected DataSet ExecuteDataset(string commandText, params IDataParameter[] commandParameters) |
168 | 147 | { |
169 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText, commandParameters) : null; |
| 148 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText, commandParameters) : null; |
170 | 149 | } |
171 | 150 |
|
172 | 151 |
|
173 | 152 | protected DataSet ExecuteDataset(string commandText) |
174 | 153 | { |
175 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText) : null; |
| 154 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText) : null; |
176 | 155 | } |
177 | 156 |
|
178 | 157 | protected DataSet ExecuteDataset(string connectionString, string commandText) |
179 | 158 | { |
180 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteDataset(connectionString, CommandType.Text, commandText) : null; |
| 159 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteDataset(connectionString, CommandType.Text, commandText) : null; |
181 | 160 | } |
182 | 161 |
|
183 | 162 | protected int ExecuteNonQuery(IDbConnection conn, CommandType commandType, string commandText, params IDataParameter[] commandParameters) |
184 | 163 | { |
185 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(conn, commandType, commandText, commandParameters) : 0; |
| 164 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(conn, commandType, commandText, commandParameters) : 0; |
186 | 165 | } |
187 | 166 |
|
188 | 167 |
|
189 | 168 | protected int ExecuteNonQuery(IDbConnection conn, string commandText, params IDataParameter[] commandParameters) |
190 | 169 | { |
191 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters) : 0; |
| 170 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters) : 0; |
192 | 171 | } |
193 | 172 |
|
194 | 173 |
|
195 | 174 | protected int ExecuteNonQuery(IDbConnection conn, string commandText) |
196 | 175 | { |
197 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(conn, CommandType.Text, commandText) : 0; |
| 176 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(conn, CommandType.Text, commandText) : 0; |
198 | 177 | } |
199 | 178 |
|
200 | 179 |
|
201 | 180 | protected int ExecuteNonQuery(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters) |
202 | 181 | { |
203 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters) : 0; |
| 182 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters) : 0; |
204 | 183 | } |
205 | 184 |
|
206 | 185 |
|
207 | 186 | protected int ExecuteNonQuery(IDbTransaction trans, string commandText) |
208 | 187 | { |
209 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(trans, CommandType.Text, commandText) : 0; |
| 188 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(trans, CommandType.Text, commandText) : 0; |
210 | 189 | } |
211 | 190 |
|
212 | 191 | protected int ExecuteNonQuery(string connectionString, string commandText, params IDataParameter[] commandParameters) |
213 | 192 | { |
214 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(connectionString, CommandType.Text, commandText, commandParameters) : 0; |
| 193 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(connectionString, CommandType.Text, commandText, commandParameters) : 0; |
215 | 194 | } |
216 | 195 |
|
217 | 196 |
|
218 | 197 | protected int ExecuteNonQuery(string commandText, params IDataParameter[] commandParameters) |
219 | 198 | { |
220 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText, commandParameters) : 0; |
| 199 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText, commandParameters) : 0; |
221 | 200 | } |
222 | 201 |
|
223 | 202 |
|
224 | 203 | protected int ExecuteNonQuery(string commandText) |
225 | 204 | { |
226 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText) : 0; |
| 205 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText) : 0; |
227 | 206 | } |
228 | 207 |
|
229 | 208 | protected int ExecuteNonQueryAndReturnId(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters) |
230 | 209 | { |
231 | 210 | if (string.IsNullOrEmpty(commandText)) return 0; |
232 | 211 |
|
233 | 212 | var id = 0; |
234 | | - Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters); |
| 213 | + WebConfigUtils.Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters); |
235 | 214 |
|
236 | 215 | using (var rdr = ExecuteReader(trans, "SELECT @@IDENTITY AS 'ID'")) |
237 | 216 | { |
@@ -259,37 +238,37 @@ protected int ExecuteNonQueryAndReturnId(IDbTransaction trans, string commandTex |
259 | 238 |
|
260 | 239 | protected object ExecuteScalar(IDbConnection conn, string commandText, params IDataParameter[] commandParameters) |
261 | 240 | { |
262 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(conn, CommandType.Text, commandText, commandParameters) : null; |
| 241 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(conn, CommandType.Text, commandText, commandParameters) : null; |
263 | 242 | } |
264 | 243 |
|
265 | 244 |
|
266 | 245 | protected object ExecuteScalar(IDbConnection conn, string commandText) |
267 | 246 | { |
268 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(conn, CommandType.Text, commandText) : null; |
| 247 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(conn, CommandType.Text, commandText) : null; |
269 | 248 | } |
270 | 249 |
|
271 | 250 |
|
272 | 251 | protected object ExecuteScalar(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters) |
273 | 252 | { |
274 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(trans, CommandType.Text, commandText, commandParameters) : null; |
| 253 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(trans, CommandType.Text, commandText, commandParameters) : null; |
275 | 254 | } |
276 | 255 |
|
277 | 256 |
|
278 | 257 | protected object ExecuteScalar(IDbTransaction trans, string commandText) |
279 | 258 | { |
280 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(trans, CommandType.Text, commandText) : null; |
| 259 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(trans, CommandType.Text, commandText) : null; |
281 | 260 | } |
282 | 261 |
|
283 | 262 |
|
284 | 263 | protected object ExecuteScalar(string commandText, params IDataParameter[] commandParameters) |
285 | 264 | { |
286 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText, commandParameters) : null; |
| 265 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText, commandParameters) : null; |
287 | 266 | } |
288 | 267 |
|
289 | 268 |
|
290 | 269 | protected object ExecuteScalar(string commandText) |
291 | 270 | { |
292 | | - return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText) : null; |
| 271 | + return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText) : null; |
293 | 272 | } |
294 | 273 |
|
295 | 274 | protected string GetString(IDataReader rdr, int i) |
|
0 commit comments