Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlExpressionVisitorDependency -> QuerySqlGeneratorDependencies #16847

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices()
.AddDependencySingleton<RelationalMemberTranslatorProviderDependencies>()
.AddDependencySingleton<RelationalSqlTranslatingExpressionVisitorDependencies>()
.AddDependencySingleton<RelationalQueryableMethodTranslatingExpressionVisitorDependencies>()
.AddDependencySingleton<SqlExpressionVisitorDependencies>()
.AddDependencySingleton<QuerySqlGeneratorDependencies>()
.AddDependencySingleton<RelationalShapedQueryCompilingExpressionVisitorDependencies>()
.AddDependencySingleton<RelationalShapedQueryOptimizerDependencies>()
.AddDependencyScoped<MigrationsSqlGeneratorDependencies>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions src/EFCore.Relational/Query/QuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query
{
/// <summary>
/// <para>
/// Service dependencies parameter class for <see cref="SqlExpressionVisitor" />
/// Service dependencies parameter class for <see cref="QuerySqlGenerator" />
/// </para>
/// <para>
/// This type is typically used by database providers (and other extensions). It is generally
Expand All @@ -31,11 +31,11 @@ namespace Microsoft.EntityFrameworkCore.Query
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped"/>.
/// </para>
/// </summary>
public sealed class SqlExpressionVisitorDependencies
public sealed class QuerySqlGeneratorDependencies
{
/// <summary>
/// <para>
/// Creates the service dependencies parameter object for a <see cref="SqlExpressionVisitor" />.
/// Creates the service dependencies parameter object for a <see cref="QuerySqlGenerator" />.
/// </para>
/// <para>
/// Do not call this constructor directly from either provider or application code as it may change
Expand All @@ -53,7 +53,7 @@ public sealed class SqlExpressionVisitorDependencies
/// </para>
/// </summary>
[EntityFrameworkInternal]
public SqlExpressionVisitorDependencies(
public QuerySqlGeneratorDependencies(
[NotNull] IRelationalCommandBuilderFactory relationalCommandBuilderFactory,
[NotNull] ISqlGenerationHelper sqlGenerationHelper)
{
Expand All @@ -79,15 +79,15 @@ public SqlExpressionVisitorDependencies(
/// </summary>
/// <param name="relationalCommandBuilderFactory"> A replacement for the current dependency of this type. </param>
/// <returns> A new parameter object with the given service replaced. </returns>
public SqlExpressionVisitorDependencies With([NotNull] IRelationalCommandBuilderFactory relationalCommandBuilderFactory)
=> new SqlExpressionVisitorDependencies(relationalCommandBuilderFactory, SqlGenerationHelper);
public QuerySqlGeneratorDependencies With([NotNull] IRelationalCommandBuilderFactory relationalCommandBuilderFactory)
=> new QuerySqlGeneratorDependencies(relationalCommandBuilderFactory, SqlGenerationHelper);

/// <summary>
/// Clones this dependency parameter object with one service replaced.
/// </summary>
/// <param name="sqlGenerationHelper"> A replacement for the current dependency of this type. </param>
/// <returns> A new parameter object with the given service replaced. </returns>
public SqlExpressionVisitorDependencies With([NotNull] ISqlGenerationHelper sqlGenerationHelper)
=> new SqlExpressionVisitorDependencies(RelationalCommandBuilderFactory, sqlGenerationHelper);
public QuerySqlGeneratorDependencies With([NotNull] ISqlGenerationHelper sqlGenerationHelper)
=> new QuerySqlGeneratorDependencies(RelationalCommandBuilderFactory, sqlGenerationHelper);
}
}
8 changes: 0 additions & 8 deletions src/EFCore.Relational/Query/SqlExpressionVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public class SearchConditionConvertingExpressionVisitor : SqlExpressionVisitor
private readonly ISqlExpressionFactory _sqlExpressionFactory;

public SearchConditionConvertingExpressionVisitor(
SqlExpressionVisitorDependencies dependencies,
ISqlExpressionFactory sqlExpressionFactory)
: base(dependencies)
{
_sqlExpressionFactory = sqlExpressionFactory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
{
public class SqlServerQuerySqlGenerator : QuerySqlGenerator
{
public SqlServerQuerySqlGenerator(SqlExpressionVisitorDependencies dependencies)
public SqlServerQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies)
: base(dependencies)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -25,7 +22,6 @@ public virtual ShapedQueryOptimizer Create(QueryCompilationContext queryCompilat
=> new SqlServerShapedQueryOptimizer(
_dependencies,
_relationalDependencies,
_sqlExpressionVisitorDependencies,
queryCompilationContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal
{
public class SqliteQuerySqlGenerator : QuerySqlGenerator
{
public SqliteQuerySqlGenerator(SqlExpressionVisitorDependencies dependencies)
public SqliteQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies)
: base(dependencies)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SqlExpressionVisitorDependencies>();
RelationalTestHelpers.Instance.TestDependenciesClone<QuerySqlGeneratorDependencies>();
}
}
}