File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -270,5 +270,26 @@ public async Task PlansWithNonParameterizedConstantsAreNotCachedAsync()
270
270
Has . Count . EqualTo ( 0 ) ,
271
271
"Query plan should not be cached." ) ;
272
272
}
273
+
274
+ [ Test ]
275
+ public async Task PlansWithNonParameterizedConstantsAreNotCachedForExpandedQueryAsync ( )
276
+ {
277
+ var queryPlanCacheType = typeof ( QueryPlanCache ) ;
278
+
279
+ var cache = ( SoftLimitMRUCache )
280
+ queryPlanCacheType
281
+ . GetField ( "planCache" , BindingFlags . Instance | BindingFlags . NonPublic )
282
+ . GetValue ( Sfi . QueryPlanCache ) ;
283
+ cache . Clear ( ) ;
284
+
285
+ var ids = new [ ] { "ANATR" , "UNKNOWN" } . ToList ( ) ;
286
+ await ( db . Customers . Where ( x => ids . Contains ( x . CustomerId ) ) . Select (
287
+ c => new { c . CustomerId , c . ContactName , Constant = 1 } ) . FirstAsync ( ) ) ;
288
+
289
+ Assert . That (
290
+ cache ,
291
+ Has . Count . EqualTo ( 0 ) ,
292
+ "Query plan should not be cached." ) ;
293
+ }
273
294
}
274
295
}
Original file line number Diff line number Diff line change @@ -313,5 +313,26 @@ public void PlansWithNonParameterizedConstantsAreNotCached()
313
313
Has . Count . EqualTo ( 0 ) ,
314
314
"Query plan should not be cached." ) ;
315
315
}
316
+
317
+ [ Test ]
318
+ public void PlansWithNonParameterizedConstantsAreNotCachedForExpandedQuery ( )
319
+ {
320
+ var queryPlanCacheType = typeof ( QueryPlanCache ) ;
321
+
322
+ var cache = ( SoftLimitMRUCache )
323
+ queryPlanCacheType
324
+ . GetField ( "planCache" , BindingFlags . Instance | BindingFlags . NonPublic )
325
+ . GetValue ( Sfi . QueryPlanCache ) ;
326
+ cache . Clear ( ) ;
327
+
328
+ var ids = new [ ] { "ANATR" , "UNKNOWN" } . ToList ( ) ;
329
+ db . Customers . Where ( x => ids . Contains ( x . CustomerId ) ) . Select (
330
+ c => new { c . CustomerId , c . ContactName , Constant = 1 } ) . First ( ) ;
331
+
332
+ Assert . That (
333
+ cache ,
334
+ Has . Count . EqualTo ( 0 ) ,
335
+ "Query plan should not be cached." ) ;
336
+ }
316
337
}
317
338
}
You can’t perform that action at this time.
0 commit comments