diff --git a/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs b/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs index 720b0ab64b9..479615b4c19 100644 --- a/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs +++ b/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs @@ -185,7 +185,7 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices() .AddDependencySingleton() .AddDependencySingleton() .AddDependencySingleton() - .AddDependencySingleton() + .AddDependencySingleton() .AddDependencySingleton() .AddDependencySingleton() .AddDependencyScoped() diff --git a/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs b/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs index e22651fa522..f59687622e7 100644 --- a/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs +++ b/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal { public class QuerySqlGeneratorFactory : IQuerySqlGeneratorFactory { - private readonly SqlExpressionVisitorDependencies _dependencies; + private readonly QuerySqlGeneratorDependencies _dependencies; - public QuerySqlGeneratorFactory(SqlExpressionVisitorDependencies dependencies) + public QuerySqlGeneratorFactory(QuerySqlGeneratorDependencies dependencies) { _dependencies = dependencies; } diff --git a/src/EFCore.Relational/Query/QuerySqlGenerator.cs b/src/EFCore.Relational/Query/QuerySqlGenerator.cs index fd03893b588..9362748db4b 100644 --- a/src/EFCore.Relational/Query/QuerySqlGenerator.cs +++ b/src/EFCore.Relational/Query/QuerySqlGenerator.cs @@ -38,13 +38,16 @@ public class QuerySqlGenerator : SqlExpressionVisitor { ExpressionType.Or, " | " } }; - public QuerySqlGenerator(SqlExpressionVisitorDependencies dependencies) - : base(dependencies) + public QuerySqlGenerator(QuerySqlGeneratorDependencies dependencies) { + Dependencies = dependencies; + _relationalCommandBuilderFactory = dependencies.RelationalCommandBuilderFactory; _sqlGenerationHelper = dependencies.SqlGenerationHelper; } + protected virtual QuerySqlGeneratorDependencies Dependencies { get; } + public virtual IRelationalCommand GetCommand(SelectExpression selectExpression) { _relationalCommandBuilder = _relationalCommandBuilderFactory.Create(); diff --git a/src/EFCore.Relational/Query/SqlExpressionVisitorDependencies.cs b/src/EFCore.Relational/Query/QuerySqlGeneratorDependencies.cs similarity index 88% rename from src/EFCore.Relational/Query/SqlExpressionVisitorDependencies.cs rename to src/EFCore.Relational/Query/QuerySqlGeneratorDependencies.cs index b254c10cbd6..edca49b24ee 100644 --- a/src/EFCore.Relational/Query/SqlExpressionVisitorDependencies.cs +++ b/src/EFCore.Relational/Query/QuerySqlGeneratorDependencies.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query { /// /// - /// Service dependencies parameter class for + /// Service dependencies parameter class for /// /// /// This type is typically used by database providers (and other extensions). It is generally @@ -31,11 +31,11 @@ namespace Microsoft.EntityFrameworkCore.Query /// This service cannot depend on services registered as . /// /// - public sealed class SqlExpressionVisitorDependencies + public sealed class QuerySqlGeneratorDependencies { /// /// - /// Creates the service dependencies parameter object for a . + /// Creates the service dependencies parameter object for a . /// /// /// Do not call this constructor directly from either provider or application code as it may change @@ -53,7 +53,7 @@ public sealed class SqlExpressionVisitorDependencies /// /// [EntityFrameworkInternal] - public SqlExpressionVisitorDependencies( + public QuerySqlGeneratorDependencies( [NotNull] IRelationalCommandBuilderFactory relationalCommandBuilderFactory, [NotNull] ISqlGenerationHelper sqlGenerationHelper) { @@ -79,15 +79,15 @@ public SqlExpressionVisitorDependencies( /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. - public SqlExpressionVisitorDependencies With([NotNull] IRelationalCommandBuilderFactory relationalCommandBuilderFactory) - => new SqlExpressionVisitorDependencies(relationalCommandBuilderFactory, SqlGenerationHelper); + public QuerySqlGeneratorDependencies With([NotNull] IRelationalCommandBuilderFactory relationalCommandBuilderFactory) + => new QuerySqlGeneratorDependencies(relationalCommandBuilderFactory, SqlGenerationHelper); /// /// Clones this dependency parameter object with one service replaced. /// /// A replacement for the current dependency of this type. /// A new parameter object with the given service replaced. - public SqlExpressionVisitorDependencies With([NotNull] ISqlGenerationHelper sqlGenerationHelper) - => new SqlExpressionVisitorDependencies(RelationalCommandBuilderFactory, sqlGenerationHelper); + public QuerySqlGeneratorDependencies With([NotNull] ISqlGenerationHelper sqlGenerationHelper) + => new QuerySqlGeneratorDependencies(RelationalCommandBuilderFactory, sqlGenerationHelper); } } diff --git a/src/EFCore.Relational/Query/SqlExpressionVisitor.cs b/src/EFCore.Relational/Query/SqlExpressionVisitor.cs index 160e04eb19c..ce3dd312379 100644 --- a/src/EFCore.Relational/Query/SqlExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/SqlExpressionVisitor.cs @@ -9,14 +9,6 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class SqlExpressionVisitor : ExpressionVisitor { - - protected SqlExpressionVisitor(SqlExpressionVisitorDependencies dependencies) - { - Dependencies = dependencies; - } - - protected virtual SqlExpressionVisitorDependencies Dependencies { get; } - protected override Expression VisitExtension(Expression extensionExpression) { switch (extensionExpression) diff --git a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs index 1a60fb9b087..517c095c29c 100644 --- a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs @@ -15,9 +15,7 @@ public class SearchConditionConvertingExpressionVisitor : SqlExpressionVisitor private readonly ISqlExpressionFactory _sqlExpressionFactory; public SearchConditionConvertingExpressionVisitor( - SqlExpressionVisitorDependencies dependencies, ISqlExpressionFactory sqlExpressionFactory) - : base(dependencies) { _sqlExpressionFactory = sqlExpressionFactory; } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs index ecc8ab712c9..8c36f64d379 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { public class SqlServerQuerySqlGenerator : QuerySqlGenerator { - public SqlServerQuerySqlGenerator(SqlExpressionVisitorDependencies dependencies) + public SqlServerQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies) : base(dependencies) { } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGeneratorFactory.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGeneratorFactory.cs index caac945776f..436a5ec4ac8 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGeneratorFactory.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGeneratorFactory.cs @@ -7,9 +7,9 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { public class SqlServerQuerySqlGeneratorFactory : IQuerySqlGeneratorFactory { - private readonly SqlExpressionVisitorDependencies _dependencies; + private readonly QuerySqlGeneratorDependencies _dependencies; - public SqlServerQuerySqlGeneratorFactory(SqlExpressionVisitorDependencies dependencies) + public SqlServerQuerySqlGeneratorFactory(QuerySqlGeneratorDependencies dependencies) { _dependencies = dependencies; } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitors.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitors.cs index 584b4eca0b4..324acfe699a 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitors.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitors.cs @@ -8,22 +8,18 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { public class SqlServerShapedQueryOptimizer : RelationalShapedQueryOptimizer { - private readonly SqlExpressionVisitorDependencies _sqlExpressionVisitorDependencies; - public SqlServerShapedQueryOptimizer( ShapedQueryOptimizerDependencies dependencies, RelationalShapedQueryOptimizerDependencies relationalDependencies, - SqlExpressionVisitorDependencies sqlExpressionVisitorDependencies, QueryCompilationContext queryCompilationContext) : base(dependencies, relationalDependencies, queryCompilationContext) { - _sqlExpressionVisitorDependencies = sqlExpressionVisitorDependencies; } public override Expression Visit(Expression query) { query = base.Visit(query); - query = new SearchConditionConvertingExpressionVisitor(_sqlExpressionVisitorDependencies, SqlExpressionFactory).Visit(query); + query = new SearchConditionConvertingExpressionVisitor(SqlExpressionFactory).Visit(query); query = new SqlExpressionOptimizingVisitor(SqlExpressionFactory, UseRelationalNulls).Visit(query); return query; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs index e96ec42937e..c06ce13d57f 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs @@ -7,16 +7,13 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { public class SqlServerShapedQueryOptimizerFactory : IShapedQueryOptimizerFactory { - private readonly SqlExpressionVisitorDependencies _sqlExpressionVisitorDependencies; private readonly ShapedQueryOptimizerDependencies _dependencies; private readonly RelationalShapedQueryOptimizerDependencies _relationalDependencies; public SqlServerShapedQueryOptimizerFactory( - SqlExpressionVisitorDependencies sqlExpressionVisitorDependencies, ShapedQueryOptimizerDependencies dependencies, RelationalShapedQueryOptimizerDependencies relationalDependencies) { - _sqlExpressionVisitorDependencies = sqlExpressionVisitorDependencies; _dependencies = dependencies; _relationalDependencies = relationalDependencies; } @@ -25,7 +22,6 @@ public virtual ShapedQueryOptimizer Create(QueryCompilationContext queryCompilat => new SqlServerShapedQueryOptimizer( _dependencies, _relationalDependencies, - _sqlExpressionVisitorDependencies, queryCompilationContext); } } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGenerator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGenerator.cs index eac7b9b2a4f..d5cf5956ef6 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGenerator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGenerator.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal { public class SqliteQuerySqlGenerator : QuerySqlGenerator { - public SqliteQuerySqlGenerator(SqlExpressionVisitorDependencies dependencies) + public SqliteQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies) : base(dependencies) { } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGeneratorFactory.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGeneratorFactory.cs index b1d7fdcc399..a9ad0b36015 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGeneratorFactory.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGeneratorFactory.cs @@ -7,9 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal { public class SqliteQuerySqlGeneratorFactory : IQuerySqlGeneratorFactory { - private readonly SqlExpressionVisitorDependencies _dependencies; + private readonly QuerySqlGeneratorDependencies _dependencies; - public SqliteQuerySqlGeneratorFactory(SqlExpressionVisitorDependencies dependencies) + public SqliteQuerySqlGeneratorFactory(QuerySqlGeneratorDependencies dependencies) { _dependencies = dependencies; } diff --git a/test/EFCore.Relational.Tests/Query/SqlExpressionVisitorDependenciesTest.cs b/test/EFCore.Relational.Tests/Query/QuerySqlGeneratorDependenciesTest.cs similarity index 83% rename from test/EFCore.Relational.Tests/Query/SqlExpressionVisitorDependenciesTest.cs rename to test/EFCore.Relational.Tests/Query/QuerySqlGeneratorDependenciesTest.cs index 951160236e5..9ad38a0db1c 100644 --- a/test/EFCore.Relational.Tests/Query/SqlExpressionVisitorDependenciesTest.cs +++ b/test/EFCore.Relational.Tests/Query/QuerySqlGeneratorDependenciesTest.cs @@ -6,12 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class SqlExpressionVisitorDependenciesTest + public class QuerySqlGeneratorDependenciesTest { [ConditionalFact] public void Can_use_With_methods_to_clone_and_replace_service() { - RelationalTestHelpers.Instance.TestDependenciesClone(); + RelationalTestHelpers.Instance.TestDependenciesClone(); } } }