@@ -71,9 +71,10 @@ public int? CommandTimeout
7171 {
7272 get => commandTimeout ;
7373 set {
74- if ( value != null ) {
74+ if ( value != null ) {
7575 ArgumentValidator . EnsureArgumentIsInRange ( value . Value , 0 , 65535 , nameof ( value ) ) ;
7676 }
77+
7778 EnsureIsNotDisposed ( ) ;
7879
7980 commandTimeout = value ;
@@ -93,7 +94,7 @@ public DbCommand CreateCommand()
9394 {
9495 EnsureIsNotDisposed ( ) ;
9596 var command = CreateNativeCommand ( ) ;
96- if ( commandTimeout != null ) {
97+ if ( commandTimeout != null ) {
9798 command . CommandTimeout = commandTimeout . Value ;
9899 }
99100
@@ -175,8 +176,10 @@ public virtual void Open()
175176 public virtual void OpenAndInitialize ( string initializationScript )
176177 {
177178 UnderlyingConnection . Open ( ) ;
178- if ( string . IsNullOrEmpty ( initializationScript ) )
179+ if ( string . IsNullOrEmpty ( initializationScript ) ) {
179180 return ;
181+ }
182+
180183 using ( var command = UnderlyingConnection . CreateCommand ( ) ) {
181184 command . CommandText = initializationScript ;
182185 command . ExecuteNonQuery ( ) ;
@@ -204,8 +207,10 @@ public virtual async Task OpenAndInitializeAsync(string initializationScript, Ca
204207 {
205208 cancellationToken . ThrowIfCancellationRequested ( ) ;
206209 await UnderlyingConnection . OpenAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
207- if ( string . IsNullOrEmpty ( initializationScript ) )
210+ if ( string . IsNullOrEmpty ( initializationScript ) ) {
208211 return ;
212+ }
213+
209214 try {
210215 using ( var command = UnderlyingConnection . CreateCommand ( ) ) {
211216 command . CommandText = initializationScript ;
@@ -342,7 +347,7 @@ public void Dispose()
342347 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
343348 protected void EnsureTransactionIsActive ( )
344349 {
345- if ( ActiveTransaction == null ) {
350+ if ( ActiveTransaction == null ) {
346351 throw new InvalidOperationException ( Strings . ExTransactionShouldBeActive ) ;
347352 }
348353 }
@@ -352,7 +357,7 @@ protected void EnsureTransactionIsActive()
352357 /// </summary>
353358 protected void EnsureTransactionIsNotActive ( )
354359 {
355- if ( ActiveTransaction != null ) {
360+ if ( ActiveTransaction != null ) {
356361 throw new InvalidOperationException ( Strings . ExTransactionShouldNotBeActive ) ;
357362 }
358363 }
0 commit comments