public virtual (SelectExpression selectExpression, bool canCache) Optimize( [NotNull] SelectExpression selectExpression, [NotNull] IReadOnlyDictionary <string, object> parametersValues) { Check.NotNull(selectExpression, nameof(selectExpression)); Check.NotNull(parametersValues, nameof(parametersValues)); var canCache = true; var inExpressionOptimized = new InExpressionValuesExpandingExpressionVisitor( Dependencies.SqlExpressionFactory, parametersValues).Visit(selectExpression); if (!ReferenceEquals(selectExpression, inExpressionOptimized)) { canCache = false; } var nullParametersOptimized = new ParameterNullabilityBasedSqlExpressionOptimizingExpressionVisitor( Dependencies.SqlExpressionFactory, UseRelationalNulls, parametersValues).Visit(inExpressionOptimized); var fromSqlParameterOptimized = new FromSqlParameterApplyingExpressionVisitor( Dependencies.SqlExpressionFactory, Dependencies.ParameterNameGeneratorFactory.Create(), parametersValues).Visit(nullParametersOptimized); if (!ReferenceEquals(nullParametersOptimized, fromSqlParameterOptimized)) { canCache = false; } return(selectExpression : (SelectExpression)fromSqlParameterOptimized, canCache); }
public (SelectExpression selectExpression, bool canCache) Optimize(SelectExpression selectExpression, IReadOnlyDictionary <string, object> parametersValues) { var canCache = true; var inExpressionOptimized = new InExpressionValuesExpandingExpressionVisitor( _sqlExpressionFactory, parametersValues).Visit(selectExpression); if (!ReferenceEquals(selectExpression, inExpressionOptimized)) { canCache = false; } var nullParametersOptimized = new ParameterNullabilityBasedSqlExpressionOptimizingExpressionVisitor( _sqlExpressionFactory, _useRelationalNulls, parametersValues).Visit(inExpressionOptimized); var fromSqlParameterOptimized = new FromSqlParameterApplyingExpressionVisitor( _sqlExpressionFactory, _parameterNameGeneratorFactory.Create(), parametersValues).Visit(nullParametersOptimized); if (!ReferenceEquals(nullParametersOptimized, fromSqlParameterOptimized)) { canCache = false; } return(selectExpression : (SelectExpression)fromSqlParameterOptimized, canCache); }
public virtual (SelectExpression, bool) Optimize( [NotNull] SelectExpression selectExpression, [NotNull] IReadOnlyDictionary <string, object> parametersValues) { Check.NotNull(selectExpression, nameof(selectExpression)); Check.NotNull(parametersValues, nameof(parametersValues)); var canCache = true; var(sqlExpressionOptimized, optimizerCanCache) = new NullabilityBasedSqlProcessingExpressionVisitor( Dependencies.SqlExpressionFactory, parametersValues, UseRelationalNulls).Process(selectExpression); canCache &= optimizerCanCache; var fromSqlParameterOptimized = new FromSqlParameterApplyingExpressionVisitor( Dependencies.SqlExpressionFactory, Dependencies.TypeMappingSource, Dependencies.ParameterNameGeneratorFactory.Create(), parametersValues).Visit(sqlExpressionOptimized); if (!ReferenceEquals(sqlExpressionOptimized, fromSqlParameterOptimized)) { canCache = false; } return((SelectExpression)fromSqlParameterOptimized, canCache); }
public SelectExpression Optimize(SelectExpression selectExpression, IReadOnlyDictionary <string, object> parametersValues) { var query = new InExpressionValuesExpandingExpressionVisitor( _sqlExpressionFactory, parametersValues).Visit(selectExpression); query = new FromSqlParameterApplyingExpressionVisitor( _sqlExpressionFactory, _parameterNameGeneratorFactory.Create(), parametersValues).Visit(query); return((SelectExpression)query); }