@@ -179,138 +179,115 @@ public TThis UseCancellationToken(CancellationToken token)
179
179
}
180
180
181
181
#region AddParam
182
+
182
183
/// <summary>
183
184
/// Adds a parameter to the params list.
184
185
/// </summary>
185
186
/// <param name="name">The name of the parameter.</param>
186
187
/// <param name="value">The value of the parameter.</param>
187
188
/// <param name="type">The database type of the parameter.</param>
189
+ /// <param name="direction">The direction of the parameter.</param>
188
190
/// <returns>This instance for use in method chaining.</returns>
189
- public TThis AddParam ( string name , object value , TDbType type )
191
+ /// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception>
192
+ /// <exception cref="ArgumentException"><paramref name="name"/> is blank.</exception>
193
+ public TThis AddParam ( string name , object value , TDbType type , ParameterDirection direction = ParameterDirection . Input )
190
194
{
191
195
if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
192
- else if ( string . IsNullOrWhiteSpace ( name ) )
196
+ if ( string . IsNullOrWhiteSpace ( name ) )
193
197
throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
194
198
Contract . EndContractBlock ( ) ;
195
199
196
- Params . Add ( new Param
197
- {
198
- Name = name ,
199
- Value = value ,
200
- Type = type
201
- } ) ;
202
-
200
+ Params . Add ( new ( name , value , type , direction ) ) ;
203
201
return ( TThis ) this ;
204
202
}
205
203
206
- /// <summary>
207
- /// Adds a parameter to the params list.
208
- /// </summary>
209
- /// <param name="name">The name of the parameter.</param>
210
- /// <param name="value">The value of the parameter.</param>
211
- /// <returns>This instance for use in method chaining.</returns>
212
- public TThis AddParam ( string name , object value )
204
+ /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
205
+ public TThis AddParam ( string name , object ? value , ParameterDirection direction = ParameterDirection . Input )
213
206
{
214
207
if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
215
- else if ( string . IsNullOrWhiteSpace ( name ) )
208
+ if ( string . IsNullOrWhiteSpace ( name ) )
216
209
throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
217
210
Contract . EndContractBlock ( ) ;
218
211
219
- Params . Add ( new Param
220
- {
221
- Name = name ,
222
- Value = value ?? DBNull . Value
223
- } ) ;
224
-
212
+ Params . Add ( new ( name , value ?? DBNull . Value , null , direction ) ) ;
225
213
return ( TThis ) this ;
226
214
}
227
215
228
- /// <summary>
229
- /// Adds a parameter to the params list.
230
- /// </summary>
231
- /// <param name="name">The name of the parameter.</param>
232
- /// <param name="value">The value of the parameter.</param>
233
- /// <param name="type">The database type of the parameter.</param>
234
- /// <returns>This instance for use in method chaining.</returns>
235
- public TThis AddParam < T > ( string name , T ? value , TDbType type )
216
+ /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
217
+ public TThis AddParam < T > ( string name , T ? value , TDbType ? type = null , ParameterDirection direction = ParameterDirection . Input )
236
218
where T : struct
237
219
{
238
220
if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
239
- else if ( string . IsNullOrWhiteSpace ( name ) )
221
+ if ( string . IsNullOrWhiteSpace ( name ) )
240
222
throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
241
223
Contract . EndContractBlock ( ) ;
242
224
243
- Params . Add ( new Param
244
- {
245
- Name = name ,
246
- Type = type ,
247
- Value = value ?? ( object ) DBNull . Value
248
- } ) ;
225
+ Params . Add ( new ( name , value ?? ( object ) DBNull . Value , type , direction ) ) ;
226
+ return ( TThis ) this ;
227
+ }
228
+
229
+ /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
230
+ public TThis AddParam ( string name , string ? value , TDbType ? type = null , ParameterDirection direction = ParameterDirection . Input )
231
+ {
232
+ if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
233
+ if ( string . IsNullOrWhiteSpace ( name ) )
234
+ throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
235
+ Contract . EndContractBlock ( ) ;
249
236
237
+ Params . Add ( new ( name , value ?? ( object ) DBNull . Value , type , direction ) ) ;
250
238
return ( TThis ) this ;
251
239
}
252
240
253
- /// <summary>
254
- /// Adds a parameter to the params list.
255
- /// </summary>
256
- /// <param name="name">The name of the parameter.</param>
257
- /// <param name="value">The value of the parameter.</param>
258
- /// <returns>This instance for use in method chaining.</returns>
259
- public TThis AddParam < T > ( string name , T ? value )
260
- where T : struct
241
+ /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
242
+ public TThis AddParam ( string name , TDbType type , ParameterDirection direction = ParameterDirection . Input )
261
243
{
262
244
if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
245
+ if ( string . IsNullOrWhiteSpace ( name ) )
246
+ throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
263
247
Contract . EndContractBlock ( ) ;
264
248
265
- Params . Add ( new Param
266
- {
267
- Name = name ,
268
- Value = value ?? ( object ) DBNull . Value
269
- } ) ;
249
+ Params . Add ( new ( name , null , type , direction ) ) ;
250
+ return ( TThis ) this ;
251
+ }
252
+
253
+ /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
254
+ public TThis AddParam ( string name , ParameterDirection direction = ParameterDirection . Input )
255
+ {
256
+ if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
257
+ if ( string . IsNullOrWhiteSpace ( name ) )
258
+ throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
259
+ Contract . EndContractBlock ( ) ;
270
260
261
+ Params . Add ( new ( name , null , null , direction ) ) ;
271
262
return ( TThis ) this ;
272
263
}
273
264
274
265
/// <summary>
275
- /// Adds a parameter to the params list.
266
+ /// Adds a return parameter to the params list.
276
267
/// </summary>
277
- /// <param name="name">The name of the parameter.</param>
278
- /// <returns>This instance for use in method chaining.</returns>
279
- public TThis AddParam ( string name )
268
+ /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
269
+ public TThis AddReturnParam ( string name , TDbType type )
280
270
{
281
271
if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
282
- else if ( string . IsNullOrWhiteSpace ( name ) )
272
+ if ( string . IsNullOrWhiteSpace ( name ) )
283
273
throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
284
274
Contract . EndContractBlock ( ) ;
285
275
286
- Params . Add ( new Param
287
- {
288
- Name = name
289
- } ) ;
290
-
276
+ Params . Add ( new ( name , null , type , ParameterDirection . ReturnValue ) ) ;
291
277
return ( TThis ) this ;
292
278
}
293
279
294
- /// <summary>
295
- /// Conditionally adds a parameter to the params list.
296
- /// </summary>
297
- /// <param name="condition">The condition to add the param by. Only adds if true.</param>
298
- /// <param name="name">The name of the parameter.</param>
299
- /// <param name="value">The value of the parameter.</param>
300
- /// <returns>This instance for use in method chaining.</returns>
301
- public TThis AddParamIf < T > ( bool condition , string name , T ? value )
302
- where T : struct
303
- => condition ? AddParam ( name , value ) : ( TThis ) this ;
280
+ /// <inheritdoc cref="AddReturnParam(string, TDbType)"/>
281
+ public TThis AddReturnParam ( string name )
282
+ {
283
+ if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
284
+ if ( string . IsNullOrWhiteSpace ( name ) )
285
+ throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
286
+ Contract . EndContractBlock ( ) ;
304
287
305
- /// <summary>
306
- /// Conditionally adds a parameter to the params list.
307
- /// </summary>
308
- /// <param name="condition">The condition to add the param by. Only adds if true.</param>
309
- /// <param name="name">The name of the parameter.</param>
310
- /// <param name="value">The value of the parameter.</param>
311
- /// <returns>This instance for use in method chaining.</returns>
312
- public TThis AddParamIf ( bool condition , string name , object value )
313
- => condition ? AddParam ( name , value ) : ( TThis ) this ;
288
+ Params . Add ( new ( name , null , null , ParameterDirection . ReturnValue ) ) ;
289
+ return ( TThis ) this ;
290
+ }
314
291
315
292
/// <summary>
316
293
/// Conditionally adds a parameter to the params list.
@@ -319,30 +296,32 @@ public TThis AddParamIf(bool condition, string name, object value)
319
296
/// <param name="name">The name of the parameter.</param>
320
297
/// <param name="value">The value of the parameter.</param>
321
298
/// <param name="type">The database type of the parameter.</param>
322
- /// <returns>This instance for use in method chaining.</returns>
323
- public TThis AddParamIf ( bool condition , string name , object value , TDbType type )
324
- => condition ? AddParam ( name , value , type ) : ( TThis ) this ;
299
+ /// <param name="direction">The direction of the parameter.</param>
300
+ /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
301
+ public TThis AddParamIf ( bool condition , string name , object value , TDbType type , ParameterDirection direction = ParameterDirection . Input )
302
+ => condition ? AddParam ( name , value , type , direction ) : ( TThis ) this ;
325
303
326
- /// <summary>
327
- /// Conditionally adds a parameter to the params list.
328
- /// </summary>
329
- /// <param name="condition">The condition to add the param by. Only adds if true.</param>
330
- /// <param name="name">The name of the parameter.</param>
331
- /// <param name="value">The value of the parameter.</param>
332
- /// <param name="type">The database type of the parameter.</param>
333
- /// <returns>This instance for use in method chaining.</returns>
334
- public TThis AddParamIf < T > ( bool condition , string name , T ? value , TDbType type )
304
+ /// <inheritdoc cref="AddParamIf(bool, string, object, TDbType, ParameterDirection)"/>
305
+ public TThis AddParamIf < T > ( bool condition , string name , T ? value , ParameterDirection direction = ParameterDirection . Input )
335
306
where T : struct
336
- => condition ? AddParam ( name , value , type ) : ( TThis ) this ;
307
+ => condition ? AddParam ( name , value , null , direction ) : ( TThis ) this ;
337
308
338
- /// <summary>
339
- /// Conditionally adds a parameter to the params list.
340
- /// </summary>
341
- /// <param name="condition">The condition to add the param by. Only adds if true.</param>
342
- /// <param name="name">The name of the parameter.</param>
343
- /// <returns>This instance for use in method chaining.</returns>
344
- public TThis AddParamIf ( bool condition , string name )
345
- => condition ? AddParam ( name ) : ( TThis ) this ;
309
+ /// <inheritdoc cref="AddParamIf(bool, string, object, TDbType, ParameterDirection)"/>
310
+ public TThis AddParamIf ( bool condition , string name , object ? value , ParameterDirection direction = ParameterDirection . Input )
311
+ => condition ? AddParam ( name , value , direction ) : ( TThis ) this ;
312
+
313
+ /// <inheritdoc cref="AddParamIf(bool, string, object, TDbType, ParameterDirection)"/>
314
+ public TThis AddParamIf < T > ( bool condition , string name , T ? value , TDbType ? type , ParameterDirection direction = ParameterDirection . Input )
315
+ where T : struct
316
+ => condition ? AddParam ( name , value , type , direction ) : ( TThis ) this ;
317
+
318
+ /// <inheritdoc cref="AddParamIf(bool, string, object, TDbType, ParameterDirection)"/>
319
+ public TThis AddParamIf ( bool condition , string name , TDbType type , ParameterDirection direction = ParameterDirection . Input )
320
+ => condition ? AddParam ( name , type , direction ) : ( TThis ) this ;
321
+
322
+ /// <inheritdoc cref="AddParamIf(bool, string, object, TDbType, ParameterDirection)"/>
323
+ public TThis AddParamIf ( bool condition , string name , ParameterDirection direction = ParameterDirection . Input )
324
+ => condition ? AddParam ( name , direction ) : ( TThis ) this ;
346
325
347
326
/// <summary>
348
327
/// Handles adding the list of parameters to a new command.
0 commit comments