@@ -161,47 +161,41 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
161
161
162
162
if ( RowDeleteEnabled )
163
163
{
164
- bool useBatch = true ;
164
+ IExpectation deleteExpectation = Expectations . AppropriateExpectation ( DeleteCheckStyle ) ;
165
+ bool useBatch = deleteExpectation . CanBeBatched ;
166
+ SqlCommandInfo sql = SqlDeleteRowString ;
165
167
IDbCommand st = null ;
166
168
// update removed rows fks to null
167
169
try
168
170
{
169
171
int i = 0 ;
170
172
IEnumerable entries = collection . Entries ( this ) ;
171
- IExpectation expectation = Expectations . None ;
172
173
173
174
foreach ( object entry in entries )
174
175
{
175
176
if ( collection . NeedsUpdating ( entry , i , ElementType ) )
176
177
{
177
178
// will still be issued when it used to be null
178
- if ( st == null )
179
+ if ( useBatch )
180
+ {
181
+ st = session . Batcher . PrepareBatchCommand ( SqlDeleteRowString . CommandType , sql . Text ,
182
+ SqlDeleteRowString . ParameterTypes ) ;
183
+ }
184
+ else
179
185
{
180
- SqlCommandInfo sql = SqlDeleteRowString ;
181
- if ( DeleteCallable )
182
- {
183
- expectation = Expectations . AppropriateExpectation ( DeleteCheckStyle ) ;
184
- useBatch = expectation . CanBeBatched ;
185
- st = useBatch
186
- ? session . Batcher . PrepareBatchCommand ( SqlDeleteRowString . CommandType , sql . Text , SqlDeleteRowString . ParameterTypes )
187
- : session . Batcher . PrepareCommand ( SqlDeleteRowString . CommandType , sql . Text , SqlDeleteRowString . ParameterTypes ) ;
188
- //offset += expectation.prepare(st);
189
- }
190
- else
191
- {
192
- st = session . Batcher . PrepareBatchCommand ( SqlDeleteRowString . CommandType , sql . Text , SqlDeleteRowString . ParameterTypes ) ;
193
- }
186
+ st = session . Batcher . PrepareCommand ( SqlDeleteRowString . CommandType , sql . Text ,
187
+ SqlDeleteRowString . ParameterTypes ) ;
194
188
}
195
189
196
190
int loc = WriteKey ( st , id , offset , session ) ;
197
191
WriteElementToWhere ( st , collection . GetSnapshotElement ( entry , i ) , loc , session ) ;
198
192
if ( useBatch )
199
193
{
200
- session . Batcher . AddToBatch ( expectation ) ;
194
+ session . Batcher . AddToBatch ( deleteExpectation ) ;
201
195
}
202
196
else
203
197
{
204
- expectation . VerifyOutcomeNonBatched ( session . Batcher . ExecuteNonQuery ( st ) , st ) ;
198
+ deleteExpectation . VerifyOutcomeNonBatched ( session . Batcher . ExecuteNonQuery ( st ) , st ) ;
205
199
}
206
200
count ++ ;
207
201
}
@@ -227,9 +221,9 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
227
221
228
222
if ( RowInsertEnabled )
229
223
{
230
- IExpectation expectation = Expectations . AppropriateExpectation ( InsertCheckStyle ) ;
224
+ IExpectation insertExpectation = Expectations . AppropriateExpectation ( InsertCheckStyle ) ;
231
225
//bool callable = InsertCallable;
232
- bool useBatch = expectation . CanBeBatched ;
226
+ bool useBatch = insertExpectation . CanBeBatched ;
233
227
SqlCommandInfo sql = SqlInsertRowString ;
234
228
IDbCommand st = null ;
235
229
@@ -244,17 +238,16 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
244
238
{
245
239
if ( useBatch )
246
240
{
247
- if ( st == null )
248
- {
249
- st = session . Batcher . PrepareBatchCommand ( SqlInsertRowString . CommandType , sql . Text , SqlInsertRowString . ParameterTypes ) ;
250
- }
241
+ st = session . Batcher . PrepareBatchCommand ( SqlInsertRowString . CommandType , sql . Text ,
242
+ SqlInsertRowString . ParameterTypes ) ;
251
243
}
252
244
else
253
245
{
254
- st = session . Batcher . PrepareCommand ( SqlInsertRowString . CommandType , sql . Text , SqlInsertRowString . ParameterTypes ) ;
246
+ st = session . Batcher . PrepareCommand ( SqlInsertRowString . CommandType , sql . Text ,
247
+ SqlInsertRowString . ParameterTypes ) ;
255
248
}
256
249
257
- //offset += expectation .Prepare(st, Factory.ConnectionProvider.Driver);
250
+ //offset += insertExpectation .Prepare(st, Factory.ConnectionProvider.Driver);
258
251
int loc = WriteKey ( st , id , offset , session ) ;
259
252
if ( HasIndex && ! indexContainsFormula )
260
253
{
@@ -263,11 +256,11 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
263
256
WriteElementToWhere ( st , collection . GetElement ( entry ) , loc , session ) ;
264
257
if ( useBatch )
265
258
{
266
- session . Batcher . AddToBatch ( expectation ) ;
259
+ session . Batcher . AddToBatch ( insertExpectation ) ;
267
260
}
268
261
else
269
262
{
270
- expectation . VerifyOutcomeNonBatched ( session . Batcher . ExecuteNonQuery ( st ) , st ) ;
263
+ insertExpectation . VerifyOutcomeNonBatched ( session . Batcher . ExecuteNonQuery ( st ) , st ) ;
271
264
}
272
265
count ++ ;
273
266
}
0 commit comments