33// See the LICENSE file in the project root for more information.
44
55using System ;
6+ using System . Collections . Generic ;
67using System . Data ;
78using System . Data . Common ;
89using System . Threading . Tasks ;
@@ -74,9 +75,13 @@ public static void SqlBatchCanCreateParameter()
7475 [ ConditionalFact ( typeof ( DataTestUtility ) , nameof ( DataTestUtility . AreConnStringsSetup ) ) ]
7576 public static void StoredProcedureBatchSupported ( )
7677 {
78+ SqlRetryLogicOption rto = new ( ) { NumberOfTries = 3 , DeltaTime = TimeSpan . FromMilliseconds ( 100 ) , TransientErrors = new [ ] { 1205 } } ; // Retry on 1205 / Deadlock
79+ SqlRetryLogicBaseProvider prov = SqlConfigurableRetryFactory . CreateIncrementalRetryProvider ( rto ) ;
80+
7781 using ( var connection = new SqlConnection ( DataTestUtility . TCPConnectionString ) )
78- using ( var batch = new SqlBatch { Connection = connection , BatchCommands = { new SqlBatchCommand ( "sp_help" , CommandType . StoredProcedure ) } } )
82+ using ( var batch = new SqlBatch { Connection = connection , BatchCommands = { new SqlBatchCommand ( "sp_help" , CommandType . StoredProcedure , new List < SqlParameter > { new ( "@objname" , "sys.indexes" ) } ) } } )
7983 {
84+ connection . RetryLogicProvider = prov ;
8085 connection . Open ( ) ;
8186 batch . ExecuteNonQuery ( ) ;
8287 }
@@ -102,19 +107,24 @@ public static void TableDirectBatchNotSupported()
102107 [ ConditionalFact ( typeof ( DataTestUtility ) , nameof ( DataTestUtility . AreConnStringsSetup ) ) ]
103108 public static void MixedBatchSupported ( )
104109 {
110+ SqlRetryLogicOption rto = new ( ) { NumberOfTries = 3 , DeltaTime = TimeSpan . FromMilliseconds ( 100 ) , TransientErrors = new [ ] { 1205 } } ; // Retry on 1205 / Deadlock
111+ SqlRetryLogicBaseProvider prov = SqlConfigurableRetryFactory . CreateIncrementalRetryProvider ( rto ) ;
112+
105113 using ( var connection = new SqlConnection ( DataTestUtility . TCPConnectionString ) )
106114 using ( var batch = new SqlBatch
115+ {
116+ Connection = connection ,
117+ BatchCommands =
118+ {
119+ new SqlBatchCommand ( "select @@SPID" , CommandType . Text ) ,
120+ new SqlBatchCommand ( "sp_help" , CommandType . StoredProcedure , new List < SqlParameter > { new ( "@objname" , "sys.indexes" ) } )
121+ }
122+ } )
107123 {
108- Connection = connection ,
109- BatchCommands =
110- {
111- new SqlBatchCommand ( "select @@SPID" , CommandType . Text ) ,
112- new SqlBatchCommand ( "sp_help" , CommandType . StoredProcedure )
113- }
114- } )
115- {
124+ connection . RetryLogicProvider = prov ;
116125 connection . Open ( ) ;
117126 batch . ExecuteNonQuery ( ) ;
127+ return ;
118128 }
119129 }
120130
0 commit comments