@@ -180,6 +180,15 @@ public TThis UseCancellationToken(CancellationToken token)
180180
181181 #region AddParam
182182
183+ /// <summary>
184+ /// Shortcut to add a parameter to the params list.
185+ /// </summary>
186+ protected TThis AddParam ( Param param )
187+ {
188+ Params . Add ( param ) ;
189+ return ( TThis ) this ;
190+ }
191+
183192 /// <summary>
184193 /// Adds a parameter to the params list.
185194 /// </summary>
@@ -191,103 +200,39 @@ public TThis UseCancellationToken(CancellationToken token)
191200 /// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception>
192201 /// <exception cref="ArgumentException"><paramref name="name"/> is blank.</exception>
193202 public TThis AddParam ( string name , object value , TDbType type , ParameterDirection direction = ParameterDirection . Input )
194- {
195- if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
196- if ( string . IsNullOrWhiteSpace ( name ) )
197- throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
198- Contract . EndContractBlock ( ) ;
199-
200- Params . Add ( new ( name , value , type , direction ) ) ;
201- return ( TThis ) this ;
202- }
203+ => AddParam ( new ( name , value , type , direction ) ) ;
203204
204205 /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
205206 public TThis AddParam ( string name , object ? value , ParameterDirection direction = ParameterDirection . Input )
206- {
207- if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
208- if ( string . IsNullOrWhiteSpace ( name ) )
209- throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
210- Contract . EndContractBlock ( ) ;
211-
212- Params . Add ( new ( name , value ?? DBNull . Value , null , direction ) ) ;
213- return ( TThis ) this ;
214- }
207+ => AddParam ( new ( name , value , null , direction ) ) ;
215208
216209 /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
217210 public TThis AddParam < T > ( string name , T ? value , TDbType ? type = null , ParameterDirection direction = ParameterDirection . Input )
218211 where T : struct
219- {
220- if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
221- if ( string . IsNullOrWhiteSpace ( name ) )
222- throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
223- Contract . EndContractBlock ( ) ;
224-
225- Params . Add ( new ( name , value ?? ( object ) DBNull . Value , type , direction ) ) ;
226- return ( TThis ) this ;
227- }
212+ => AddParam ( new ( name , value , type , direction ) ) ;
228213
229214 /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
230215 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 ( ) ;
236-
237- Params . Add ( new ( name , value ?? ( object ) DBNull . Value , type , direction ) ) ;
238- return ( TThis ) this ;
239- }
216+ => AddParam ( new ( name , value , type , direction ) ) ;
240217
241218 /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
242219 public TThis AddParam ( string name , TDbType type , ParameterDirection direction = ParameterDirection . Input )
243- {
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 ) ) ;
247- Contract . EndContractBlock ( ) ;
248-
249- Params . Add ( new ( name , null , type , direction ) ) ;
250- return ( TThis ) this ;
251- }
220+ => AddParam ( new ( name , null , type , direction ) ) ;
252221
253222 /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
254223 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 ( ) ;
260-
261- Params . Add ( new ( name , null , null , direction ) ) ;
262- return ( TThis ) this ;
263- }
224+ => AddParam ( new ( name , null , null , direction ) ) ;
264225
265226 /// <summary>
266227 /// Adds a return parameter to the params list.
267228 /// </summary>
268229 /// <inheritdoc cref="AddParam(string, object, TDbType, ParameterDirection)"/>
269230 public TThis AddReturnParam ( string name , TDbType type )
270- {
271- if ( name is null ) throw new ArgumentNullException ( nameof ( name ) ) ;
272- if ( string . IsNullOrWhiteSpace ( name ) )
273- throw new ArgumentException ( "Parameter names cannot be empty or white space." , nameof ( name ) ) ;
274- Contract . EndContractBlock ( ) ;
275-
276- Params . Add ( new ( name , null , type , ParameterDirection . ReturnValue ) ) ;
277- return ( TThis ) this ;
278- }
231+ => AddParam ( new ( name , null , type , ParameterDirection . ReturnValue ) ) ;
279232
280233 /// <inheritdoc cref="AddReturnParam(string, TDbType)"/>
281234 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 ( ) ;
287-
288- Params . Add ( new ( name , null , null , ParameterDirection . ReturnValue ) ) ;
289- return ( TThis ) this ;
290- }
235+ => AddParam ( new ( name , null , null , ParameterDirection . ReturnValue ) ) ;
291236
292237 /// <summary>
293238 /// Conditionally adds a parameter to the params list.
0 commit comments