@@ -61,7 +61,7 @@ public static DbCommand AddParameter(this DbCommand command, string id, string v
61
61
Length = - 1 ;
62
62
}
63
63
64
- DbParameter Parameter = command . GetOrCreateParameter ( id ) ;
64
+ var Parameter = command . GetOrCreateParameter ( id ) ;
65
65
Parameter . Value = string . IsNullOrEmpty ( value ) ? DBNull . Value : ( object ) value ;
66
66
Parameter . IsNullable = string . IsNullOrEmpty ( value ) ;
67
67
Parameter . DbType = DbType . String ;
@@ -81,7 +81,7 @@ public static DbCommand AddParameter(this DbCommand command, string id, string v
81
81
/// <returns>The DbCommand object</returns>
82
82
/// <exception cref="ArgumentNullException">command or id</exception>
83
83
public static DbCommand AddParameter ( this DbCommand command , string id , SqlDbType type ,
84
- object value = null , ParameterDirection direction = ParameterDirection . Input )
84
+ object ? value = null , ParameterDirection direction = ParameterDirection . Input )
85
85
{
86
86
if ( command == null )
87
87
throw new ArgumentNullException ( nameof ( command ) ) ;
@@ -100,16 +100,16 @@ public static DbCommand AddParameter(this DbCommand command, string id, SqlDbTyp
100
100
/// <param name="direction">Direction that the parameter goes (in or out)</param>
101
101
/// <returns>The DbCommand object</returns>
102
102
/// <exception cref="ArgumentNullException">command or id</exception>
103
- public static DbCommand AddParameter < DataType > ( this DbCommand command , string id , DataType value = default ( DataType ) ,
103
+ public static DbCommand AddParameter < DataType > ( this DbCommand command , string id , DataType value = default ,
104
104
ParameterDirection direction = ParameterDirection . Input )
105
105
{
106
106
if ( command == null )
107
107
throw new ArgumentNullException ( nameof ( command ) ) ;
108
108
if ( string . IsNullOrEmpty ( id ) )
109
109
throw new ArgumentNullException ( nameof ( id ) ) ;
110
110
return command . AddParameter ( id ,
111
- new GenericEqualityComparer < DataType > ( ) . Equals ( value , default ( DataType ) ) ? typeof ( DataType ) . To ( DbType . Int32 ) : value . GetType ( ) . To ( DbType . Int32 ) ,
112
- value , direction ) ;
111
+ new GenericEqualityComparer < DataType > ( ) . Equals ( value , default ! ) ? typeof ( DataType ) . To ( DbType . Int32 ) : value ? . GetType ( ) . To ( DbType . Int32 ) ?? DbType . Int32 ,
112
+ value ! , direction ) ;
113
113
}
114
114
115
115
/// <summary>
@@ -122,17 +122,17 @@ public static DbCommand AddParameter(this DbCommand command, string id, SqlDbTyp
122
122
/// <param name="direction">Direction that the parameter goes (in or out)</param>
123
123
/// <returns>The DbCommand object</returns>
124
124
/// <exception cref="ArgumentNullException">command or id</exception>
125
- public static DbCommand AddParameter ( this DbCommand command , string id , DbType type , object value = null ,
125
+ public static DbCommand AddParameter ( this DbCommand command , string id , DbType type , object ? value = null ,
126
126
ParameterDirection direction = ParameterDirection . Input )
127
127
{
128
128
if ( command == null )
129
129
throw new ArgumentNullException ( nameof ( command ) ) ;
130
130
if ( string . IsNullOrEmpty ( id ) )
131
131
throw new ArgumentNullException ( nameof ( id ) ) ;
132
- DbParameter Parameter = command . GetOrCreateParameter ( id ) ;
132
+ var Parameter = command . GetOrCreateParameter ( id ) ;
133
133
Parameter . IsNullable = value == null || DBNull . Value == value ;
134
134
Parameter . Value = Parameter . IsNullable ? DBNull . Value : value ;
135
- if ( type != default ( DbType ) && ! BadDbTypes . Contains ( type ) )
135
+ if ( type != default && ! BadDbTypes . Contains ( type ) )
136
136
Parameter . DbType = type ;
137
137
Parameter . Direction = direction ;
138
138
return command ;
@@ -144,7 +144,7 @@ public static DbCommand AddParameter(this DbCommand command, string id, DbType t
144
144
/// <param name="command">Command object</param>
145
145
/// <param name="retries">The retries.</param>
146
146
/// <returns>A transaction object</returns>
147
- public static DbTransaction BeginTransaction ( this DbCommand command , int retries = 0 )
147
+ public static DbTransaction ? BeginTransaction ( this DbCommand command , int retries = 0 )
148
148
{
149
149
if ( command == null || command . Connection == null )
150
150
return null ;
@@ -158,7 +158,7 @@ public static DbTransaction BeginTransaction(this DbCommand command, int retries
158
158
/// </summary>
159
159
/// <param name="command">Command object</param>
160
160
/// <returns>The DBCommand object</returns>
161
- public static DbCommand ClearParameters ( this DbCommand command )
161
+ public static DbCommand ? ClearParameters ( this DbCommand command )
162
162
{
163
163
command ? . Parameters ? . Clear ( ) ;
164
164
return command ;
@@ -169,7 +169,7 @@ public static DbCommand ClearParameters(this DbCommand command)
169
169
/// </summary>
170
170
/// <param name="command">Command object</param>
171
171
/// <returns>The DBCommand object</returns>
172
- public static DbCommand Close ( this DbCommand command )
172
+ public static DbCommand ? Close ( this DbCommand command )
173
173
{
174
174
if ( command ? . Connection != null
175
175
&& command . Connection . State != ConnectionState . Closed )
@@ -185,7 +185,7 @@ public static DbCommand Close(this DbCommand command)
185
185
/// </summary>
186
186
/// <param name="command">Command object</param>
187
187
/// <returns>The DBCommand object</returns>
188
- public static DbCommand Commit ( this DbCommand command )
188
+ public static DbCommand ? Commit ( this DbCommand command )
189
189
{
190
190
command ? . Transaction ? . Commit ( ) ;
191
191
return command ;
@@ -199,7 +199,7 @@ public static DbCommand Commit(this DbCommand command)
199
199
/// <param name="defaultValue">Default value if there is an issue</param>
200
200
/// <param name="retries">The retries.</param>
201
201
/// <returns>The object of the first row and first column</returns>
202
- public static DataType ExecuteScalar < DataType > ( this DbCommand command , DataType defaultValue = default ( DataType ) , int retries = 0 )
202
+ public static DataType ExecuteScalar < DataType > ( this DbCommand command , DataType defaultValue = default , int retries = 0 )
203
203
{
204
204
if ( command == null )
205
205
return defaultValue ;
@@ -215,7 +215,7 @@ public static DbCommand Commit(this DbCommand command)
215
215
/// <param name="defaultValue">Default value if there is an issue</param>
216
216
/// <param name="retries">The retries.</param>
217
217
/// <returns>The object of the first row and first column</returns>
218
- public static async Task < DataType > ExecuteScalarAsync < DataType > ( this DbCommand command , DataType defaultValue = default ( DataType ) , int retries = 0 )
218
+ public static async Task < DataType > ExecuteScalarAsync < DataType > ( this DbCommand command , DataType defaultValue = default , int retries = 0 )
219
219
{
220
220
if ( command == null )
221
221
return defaultValue ;
@@ -236,7 +236,7 @@ public static DbParameter GetOrCreateParameter(this DbCommand command, string id
236
236
{
237
237
return command . Parameters [ id ] ;
238
238
}
239
- DbParameter Parameter = command . CreateParameter ( ) ;
239
+ var Parameter = command . CreateParameter ( ) ;
240
240
Parameter . ParameterName = id ;
241
241
command . Parameters . Add ( Parameter ) ;
242
242
return Parameter ;
@@ -253,7 +253,7 @@ public static DbParameter GetOrCreateParameter(this DbCommand command, string id
253
253
/// if the parameter exists (and isn't null or empty), it returns the parameter's value.
254
254
/// Otherwise the default value is returned.
255
255
/// </returns>
256
- public static DataType GetOutputParameter < DataType > ( this DbCommand command , string id , DataType defaultValue = default ( DataType ) )
256
+ public static DataType GetOutputParameter < DataType > ( this DbCommand command , string id , DataType defaultValue = default )
257
257
{
258
258
return command ? . Parameters [ id ] != null ?
259
259
command . Parameters [ id ] . Value . To ( defaultValue ) :
@@ -266,9 +266,9 @@ public static DbParameter GetOrCreateParameter(this DbCommand command, string id
266
266
/// <param name="command">Command object</param>
267
267
/// <param name="retries">The retries.</param>
268
268
/// <returns>The DBCommand object</returns>
269
- public static DbCommand Open ( this DbCommand command , int retries = 0 )
269
+ public static DbCommand ? Open ( this DbCommand command , int retries = 0 )
270
270
{
271
- Exception holder = null ;
271
+ Exception ? holder = null ;
272
272
while ( retries >= 0 )
273
273
{
274
274
try
@@ -287,15 +287,15 @@ public static DbCommand Open(this DbCommand command, int retries = 0)
287
287
}
288
288
-- retries ;
289
289
}
290
- throw holder ;
290
+ throw holder ! ;
291
291
}
292
292
293
293
/// <summary>
294
294
/// Rolls back a transaction
295
295
/// </summary>
296
296
/// <param name="command">Command object</param>
297
297
/// <returns>The DBCommand object</returns>
298
- public static DbCommand Rollback ( this DbCommand command )
298
+ public static DbCommand ? Rollback ( this DbCommand command )
299
299
{
300
300
command ? . Transaction ? . Rollback ( ) ;
301
301
return command ;
0 commit comments