File tree Expand file tree Collapse file tree 2 files changed +38
-26
lines changed Expand file tree Collapse file tree 2 files changed +38
-26
lines changed Original file line number Diff line number Diff line change @@ -248,22 +248,28 @@ public async Task DmlPlansAreCachedAsync()
248
248
. GetValue ( Sfi . QueryPlanCache ) ;
249
249
cache . Clear ( ) ;
250
250
251
- await ( db . Customers . Where ( c => c . CustomerId == "ALFKI" ) . UpdateAsync ( x => new Customer { CompanyName = x . CompanyName } ) ) ;
252
- Assert . That (
253
- cache ,
254
- Has . Count . EqualTo ( 1 ) ,
255
- "First query plan should be cached." ) ;
256
-
257
- using ( var spy = new LogSpy ( queryPlanCacheType ) )
251
+ using ( session . BeginTransaction ( ) )
258
252
{
259
- // Should hit plan cache.
260
253
await ( db . Customers . Where ( c => c . CustomerId == "ALFKI" ) . UpdateAsync ( x => new Customer { CompanyName = x . CompanyName } ) ) ;
261
- Assert . That ( cache , Has . Count . EqualTo ( 1 ) , "Second query should not cause a plan to be cache." ) ;
262
254
Assert . That (
263
- spy . GetWholeLog ( ) ,
264
- Does
265
- . Contain ( "located HQL query plan in cache" )
266
- . And . Not . Contain ( "unable to locate HQL query plan in cache" ) ) ;
255
+ cache ,
256
+ Has . Count . EqualTo ( 1 ) ,
257
+ "First query plan should be cached." ) ;
258
+
259
+ using ( var spy = new LogSpy ( queryPlanCacheType ) )
260
+ {
261
+ // Should hit plan cache.
262
+ await ( db . Customers . Where ( c => c . CustomerId == "ANATR" ) . UpdateAsync ( x => new Customer { CompanyName = x . CompanyName } ) ) ;
263
+ Assert . That ( cache , Has . Count . EqualTo ( 1 ) , "Second query should not cause a plan to be cached." ) ;
264
+ Assert . That (
265
+ spy . GetWholeLog ( ) ,
266
+ Does
267
+ . Contain ( "located HQL query plan in cache" )
268
+ . And . Not . Contain ( "unable to locate HQL query plan in cache" ) ) ;
269
+
270
+ await ( db . Customers . Where ( c => c . CustomerId == "ANATR" ) . UpdateAsync ( x => new Customer { ContactName = x . ContactName } ) ) ;
271
+ Assert . That ( cache , Has . Count . EqualTo ( 2 ) , "Third query should be cached" ) ;
272
+ }
267
273
}
268
274
}
269
275
Original file line number Diff line number Diff line change @@ -269,22 +269,28 @@ public void DmlPlansAreCached()
269
269
. GetValue ( Sfi . QueryPlanCache ) ;
270
270
cache . Clear ( ) ;
271
271
272
- db . Customers . Where ( c => c . CustomerId == "ALFKI" ) . Update ( x => new Customer { CompanyName = x . CompanyName } ) ;
273
- Assert . That (
274
- cache ,
275
- Has . Count . EqualTo ( 1 ) ,
276
- "First query plan should be cached." ) ;
277
-
278
- using ( var spy = new LogSpy ( queryPlanCacheType ) )
272
+ using ( session . BeginTransaction ( ) )
279
273
{
280
- // Should hit plan cache.
281
274
db . Customers . Where ( c => c . CustomerId == "ALFKI" ) . Update ( x => new Customer { CompanyName = x . CompanyName } ) ;
282
- Assert . That ( cache , Has . Count . EqualTo ( 1 ) , "Second query should not cause a plan to be cache." ) ;
283
275
Assert . That (
284
- spy . GetWholeLog ( ) ,
285
- Does
286
- . Contain ( "located HQL query plan in cache" )
287
- . And . Not . Contain ( "unable to locate HQL query plan in cache" ) ) ;
276
+ cache ,
277
+ Has . Count . EqualTo ( 1 ) ,
278
+ "First query plan should be cached." ) ;
279
+
280
+ using ( var spy = new LogSpy ( queryPlanCacheType ) )
281
+ {
282
+ // Should hit plan cache.
283
+ db . Customers . Where ( c => c . CustomerId == "ANATR" ) . Update ( x => new Customer { CompanyName = x . CompanyName } ) ;
284
+ Assert . That ( cache , Has . Count . EqualTo ( 1 ) , "Second query should not cause a plan to be cached." ) ;
285
+ Assert . That (
286
+ spy . GetWholeLog ( ) ,
287
+ Does
288
+ . Contain ( "located HQL query plan in cache" )
289
+ . And . Not . Contain ( "unable to locate HQL query plan in cache" ) ) ;
290
+
291
+ db . Customers . Where ( c => c . CustomerId == "ANATR" ) . Update ( x => new Customer { ContactName = x . ContactName } ) ;
292
+ Assert . That ( cache , Has . Count . EqualTo ( 2 ) , "Third query should be cached" ) ;
293
+ }
288
294
}
289
295
}
290
296
You can’t perform that action at this time.
0 commit comments