@@ -81,7 +81,16 @@ protected DbCommand CurrentCommand
81
81
82
82
public DbCommand Generate ( CommandType type , SqlString sqlString , SqlType [ ] parameterTypes )
83
83
{
84
- SqlString sql = GetSQL ( sqlString ) ;
84
+ return Generate ( type , sqlString , parameterTypes , false ) ;
85
+ }
86
+
87
+ private DbCommand Generate ( CommandType type , SqlString sqlString , SqlType [ ] parameterTypes , bool batch )
88
+ {
89
+ var sql = GetSQL ( sqlString ) ;
90
+ if ( batch )
91
+ {
92
+ OnPreparedBatchStatement ( sql ) ;
93
+ }
85
94
86
95
var cmd = _factory . ConnectionProvider . Driver . GenerateCommand ( type , sql , parameterTypes ) ;
87
96
LogOpenPreparedCommand ( ) ;
@@ -141,7 +150,7 @@ public virtual DbCommand PrepareBatchCommand(CommandType type, SqlString sql, Sq
141
150
}
142
151
else
143
152
{
144
- _batchCommand = PrepareCommand ( type , sql , parameterTypes ) ; // calls ExecuteBatch()
153
+ _batchCommand = PrepareCommand ( type , sql , parameterTypes , true ) ; // calls ExecuteBatch()
145
154
_batchCommandSql = sql ;
146
155
_batchCommandParameterTypes = parameterTypes ;
147
156
}
@@ -150,14 +159,19 @@ public virtual DbCommand PrepareBatchCommand(CommandType type, SqlString sql, Sq
150
159
}
151
160
152
161
public DbCommand PrepareCommand ( CommandType type , SqlString sql , SqlType [ ] parameterTypes )
162
+ {
163
+ return PrepareCommand ( type , sql , parameterTypes , false ) ;
164
+ }
165
+
166
+ private DbCommand PrepareCommand ( CommandType type , SqlString sql , SqlType [ ] parameterTypes , bool batch )
153
167
{
154
168
OnPreparedCommand ( ) ;
155
169
156
170
// do not actually prepare the Command here - instead just generate it because
157
171
// if the command is associated with an ADO.NET Transaction/Connection while
158
172
// another open one Command is doing something then an exception will be
159
173
// thrown.
160
- return Generate ( type , sql , parameterTypes ) ;
174
+ return Generate ( type , sql , parameterTypes , batch ) ;
161
175
}
162
176
163
177
protected virtual void OnPreparedCommand ( )
@@ -167,6 +181,8 @@ protected virtual void OnPreparedCommand()
167
181
ExecuteBatch ( ) ;
168
182
}
169
183
184
+ internal virtual void OnPreparedBatchStatement ( SqlString sqlString ) { }
185
+
170
186
public DbCommand PrepareQueryCommand ( CommandType type , SqlString sql , SqlType [ ] parameterTypes )
171
187
{
172
188
// do not actually prepare the Command here - instead just generate it because
0 commit comments