3
3
// See the LICENSE file in the project root for more information.
4
4
5
5
using System ;
6
+ using System . Collections . Generic ;
6
7
using System . Data ;
7
8
using System . Data . Common ;
8
9
using System . Threading . Tasks ;
@@ -74,9 +75,13 @@ public static void SqlBatchCanCreateParameter()
74
75
[ ConditionalFact ( typeof ( DataTestUtility ) , nameof ( DataTestUtility . AreConnStringsSetup ) ) ]
75
76
public static void StoredProcedureBatchSupported ( )
76
77
{
78
+ SqlRetryLogicOption rto = new ( ) { NumberOfTries = 3 , DeltaTime = TimeSpan . FromMilliseconds ( 100 ) , TransientErrors = new [ ] { 1205 } } ; // Retry on 1205 / Deadlock
79
+ SqlRetryLogicBaseProvider prov = SqlConfigurableRetryFactory . CreateIncrementalRetryProvider ( rto ) ;
80
+
77
81
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" ) } ) } } )
79
83
{
84
+ connection . RetryLogicProvider = prov ;
80
85
connection . Open ( ) ;
81
86
batch . ExecuteNonQuery ( ) ;
82
87
}
@@ -102,19 +107,24 @@ public static void TableDirectBatchNotSupported()
102
107
[ ConditionalFact ( typeof ( DataTestUtility ) , nameof ( DataTestUtility . AreConnStringsSetup ) ) ]
103
108
public static void MixedBatchSupported ( )
104
109
{
110
+ SqlRetryLogicOption rto = new ( ) { NumberOfTries = 3 , DeltaTime = TimeSpan . FromMilliseconds ( 100 ) , TransientErrors = new [ ] { 1205 } } ; // Retry on 1205 / Deadlock
111
+ SqlRetryLogicBaseProvider prov = SqlConfigurableRetryFactory . CreateIncrementalRetryProvider ( rto ) ;
112
+
105
113
using ( var connection = new SqlConnection ( DataTestUtility . TCPConnectionString ) )
106
114
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
+ } )
107
123
{
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 ;
116
125
connection . Open ( ) ;
117
126
batch . ExecuteNonQuery ( ) ;
127
+ return ;
118
128
}
119
129
}
120
130
0 commit comments