@@ -14,32 +14,35 @@ namespace EntityFrameworkCore.Jet.Query.Internal;
1414/// any release. You should only use it directly in your code with extreme caution and knowing that
1515/// doing so can result in application failures when updating to a new Entity Framework Core release.
1616/// </remarks>
17- public class SkipTakeCollapsingExpressionVisitor ( ISqlExpressionFactory sqlExpressionFactory ) : ExpressionVisitor
17+ public class SkipTakeCollapsingExpressionVisitor : ExpressionVisitor
1818{
19- private readonly ISqlExpressionFactory _sqlExpressionFactory = sqlExpressionFactory ;
19+ private readonly ISqlExpressionFactory _sqlExpressionFactory ;
2020
21- private IReadOnlyDictionary < string , object ? > _parameterValues = null ! ;
22- private bool _canCache ;
21+ private ParametersCacheDecorator _parametersDecorator ;
2322
2423 /// <summary>
2524 /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
2625 /// the same compatibility standards as public APIs. It may be changed or removed without notice in
2726 /// any release. You should only use it directly in your code with extreme caution and knowing that
2827 /// doing so can result in application failures when updating to a new Entity Framework Core release.
2928 /// </summary>
30- public virtual Expression Process (
31- Expression queryExpression ,
32- IReadOnlyDictionary < string , object ? > parametersValues ,
33- out bool canCache )
29+ public SkipTakeCollapsingExpressionVisitor ( ISqlExpressionFactory sqlExpressionFactory )
3430 {
35- _parameterValues = parametersValues ;
36- _canCache = true ;
37-
38- var result = Visit ( queryExpression ) ;
31+ _sqlExpressionFactory = sqlExpressionFactory ;
32+ _parametersDecorator = null ! ;
33+ }
3934
40- canCache = _canCache ;
35+ /// <summary>
36+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
37+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
38+ /// any release. You should only use it directly in your code with extreme caution and knowing that
39+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
40+ /// </summary>
41+ public virtual Expression Process ( Expression queryExpression , ParametersCacheDecorator parametersDecorator )
42+ {
43+ _parametersDecorator = parametersDecorator ;
4144
42- return result ;
45+ return Visit ( queryExpression ) ;
4346 }
4447
4548 /// <summary>
@@ -73,19 +76,15 @@ bool IsZero(SqlExpression? sqlExpression)
7376 case SqlConstantExpression { Value : int intValue } :
7477 return intValue == 0 ;
7578 case SqlParameterExpression parameter :
76- _canCache = false ;
77- return _parameterValues [ parameter . Name ] is 0 ;
79+ return _parametersDecorator . GetAndDisableCaching ( ) [ parameter . Name ] is 0 ;
7880 case SqlBinaryExpression { Left : SqlConstantExpression left , Right : SqlConstantExpression right } :
7981 return left . Value is int leftValue && right . Value is int rightValue && leftValue + rightValue == 0 ;
8082 case SqlBinaryExpression { Left : SqlParameterExpression left , Right : SqlConstantExpression right } :
81- _canCache = false ;
82- return _parameterValues [ left . Name ] is 0 && right . Value is int and 0 ;
83+ return _parametersDecorator . GetAndDisableCaching ( ) [ left . Name ] is 0 && right . Value is int and 0 ;
8384 case SqlBinaryExpression { Left : SqlConstantExpression left , Right : SqlParameterExpression right } :
84- _canCache = false ;
85- return _parameterValues [ right . Name ] is 0 && left . Value is int and 0 ;
85+ return _parametersDecorator . GetAndDisableCaching ( ) [ right . Name ] is 0 && left . Value is int and 0 ;
8686 case SqlBinaryExpression { Left : SqlParameterExpression left , Right : SqlParameterExpression right } :
87- _canCache = false ;
88- return _parameterValues [ left . Name ] is 0 && _parameterValues [ right . Name ] is 0 ;
87+ return _parametersDecorator . GetAndDisableCaching ( ) [ left . Name ] is 0 && _parametersDecorator . GetAndDisableCaching ( ) [ right . Name ] is 0 ;
8988 default :
9089 return false ;
9190 }
0 commit comments