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

Add dependency objects for query services #16832

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 @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;
Expand Down Expand Up @@ -32,11 +33,12 @@ public class CosmosQueryableMethodTranslatingExpressionVisitor : QueryableMethod
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosQueryableMethodTranslatingExpressionVisitor(
[NotNull] QueryableMethodTranslatingExpressionVisitorDependencies dependencies,
IModel model,
ISqlExpressionFactory sqlExpressionFactory,
IMemberTranslatorProvider memberTranslatorProvider,
IMethodCallTranslatorProvider methodCallTranslatorProvider)
: base(subquery: false)
: base(dependencies, subquery: false)
{
_model = model;
_sqlExpressionFactory = sqlExpressionFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;

Expand All @@ -14,6 +15,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
/// </summary>
public class CosmosQueryableMethodTranslatingExpressionVisitorFactory : IQueryableMethodTranslatingExpressionVisitorFactory
{
private readonly QueryableMethodTranslatingExpressionVisitorDependencies _dependencies;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IMemberTranslatorProvider _memberTranslatorProvider;
private readonly IMethodCallTranslatorProvider _methodCallTranslatorProvider;
Expand All @@ -25,10 +27,12 @@ public class CosmosQueryableMethodTranslatingExpressionVisitorFactory : IQueryab
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosQueryableMethodTranslatingExpressionVisitorFactory(
[NotNull] QueryableMethodTranslatingExpressionVisitorDependencies dependencies,
ISqlExpressionFactory sqlExpressionFactory,
IMemberTranslatorProvider memberTranslatorProvider,
IMethodCallTranslatorProvider methodCallTranslatorProvider)
{
_dependencies = dependencies;
_sqlExpressionFactory = sqlExpressionFactory;
_memberTranslatorProvider = memberTranslatorProvider;
_methodCallTranslatorProvider = methodCallTranslatorProvider;
Expand All @@ -43,6 +47,7 @@ public CosmosQueryableMethodTranslatingExpressionVisitorFactory(
public virtual QueryableMethodTranslatingExpressionVisitor Create(IModel model)
{
return new CosmosQueryableMethodTranslatingExpressionVisitor(
_dependencies,
model,
_sqlExpressionFactory,
_memberTranslatorProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public class CosmosShapedQueryCompilingExpressionVisitor : ShapedQueryCompilingE
/// </summary>
public CosmosShapedQueryCompilingExpressionVisitor(
QueryCompilationContext queryCompilationContext,
IEntityMaterializerSource entityMaterializerSource,
ShapedQueryCompilingExpressionVisitorDependencies dependencies,
ISqlExpressionFactory sqlExpressionFactory,
IQuerySqlGeneratorFactory querySqlGeneratorFactory)
: base(queryCompilationContext, entityMaterializerSource)
: base(queryCompilationContext, dependencies)
{
_sqlExpressionFactory = sqlExpressionFactory;
_querySqlGeneratorFactory = querySqlGeneratorFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
Expand All @@ -14,7 +13,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
/// </summary>
public class CosmosShapedQueryCompilingExpressionVisitorFactory : IShapedQueryCompilingExpressionVisitorFactory
{
private readonly IEntityMaterializerSource _entityMaterializerSource;
private readonly ShapedQueryCompilingExpressionVisitorDependencies _dependencies;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;

Expand All @@ -24,11 +23,12 @@ public class CosmosShapedQueryCompilingExpressionVisitorFactory : IShapedQueryCo
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public CosmosShapedQueryCompilingExpressionVisitorFactory(IEntityMaterializerSource entityMaterializerSource,
public CosmosShapedQueryCompilingExpressionVisitorFactory(
ShapedQueryCompilingExpressionVisitorDependencies dependencies,
ISqlExpressionFactory sqlExpressionFactory,
IQuerySqlGeneratorFactory querySqlGeneratorFactory)
{
_entityMaterializerSource = entityMaterializerSource;
_dependencies = dependencies;
_sqlExpressionFactory = sqlExpressionFactory;
_querySqlGeneratorFactory = querySqlGeneratorFactory;
}
Expand All @@ -42,7 +42,7 @@ public CosmosShapedQueryCompilingExpressionVisitorFactory(IEntityMaterializerSou
public virtual ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
=> new CosmosShapedQueryCompilingExpressionVisitor(
queryCompilationContext,
_entityMaterializerSource,
_dependencies,
_sqlExpressionFactory,
_querySqlGeneratorFactory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ public class InMemoryQueryableMethodTranslatingExpressionVisitor : QueryableMeth
private readonly InMemoryProjectionBindingExpressionVisitor _projectionBindingExpressionVisitor;
private readonly IModel _model;

public InMemoryQueryableMethodTranslatingExpressionVisitor(IModel model)
: base(subquery: false)
public InMemoryQueryableMethodTranslatingExpressionVisitor(
QueryableMethodTranslatingExpressionVisitorDependencies dependencies,
IModel model)
: base(dependencies, subquery: false)
{
_expressionTranslator = new InMemoryExpressionTranslatingExpressionVisitor(this);
_projectionBindingExpressionVisitor = new InMemoryProjectionBindingExpressionVisitor(this, _expressionTranslator);
_model = model;
}

public InMemoryQueryableMethodTranslatingExpressionVisitor(
QueryableMethodTranslatingExpressionVisitorDependencies dependencies,
IModel model,
InMemoryExpressionTranslatingExpressionVisitor expressionTranslator)
: base(subquery: true)
: base(dependencies, subquery: true)
{
_expressionTranslator = expressionTranslator;
_projectionBindingExpressionVisitor = new InMemoryProjectionBindingExpressionVisitor(this, expressionTranslator);
Expand All @@ -41,8 +44,9 @@ private static Type CreateTransparentIdentifierType(Type outerType, Type innerTy
public override ShapedQueryExpression TranslateSubquery(Expression expression)
{
return (ShapedQueryExpression)new InMemoryQueryableMethodTranslatingExpressionVisitor(
_model,
_expressionTranslator)
Dependencies,
_model,
_expressionTranslator)
.Visit(expression);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
{
public class InMemoryQueryableMethodTranslatingExpressionVisitorFactory : IQueryableMethodTranslatingExpressionVisitorFactory
{
private readonly QueryableMethodTranslatingExpressionVisitorDependencies _dependencies;

public InMemoryQueryableMethodTranslatingExpressionVisitorFactory(
[NotNull] QueryableMethodTranslatingExpressionVisitorDependencies dependencies)
{
_dependencies = dependencies;
}

public virtual QueryableMethodTranslatingExpressionVisitor Create(IModel model)
=> new InMemoryQueryableMethodTranslatingExpressionVisitor(model);
=> new InMemoryQueryableMethodTranslatingExpressionVisitor(_dependencies, model);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ private static readonly ConstructorInfo _valueBufferConstructor

public InMemoryShapedQueryCompilingExpressionVisitor(
QueryCompilationContext queryCompilationContext,
IEntityMaterializerSource entityMaterializerSource)
: base(queryCompilationContext, entityMaterializerSource)
ShapedQueryCompilingExpressionVisitorDependencies dependencies)
: base(queryCompilationContext, dependencies)
{
_contextType = queryCompilationContext.ContextType;
_logger = queryCompilationContext.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
{
public class InMemoryShapedQueryCompilingExpressionVisitorFactory : IShapedQueryCompilingExpressionVisitorFactory
{
private readonly IEntityMaterializerSource _entityMaterializerSource;
private readonly ShapedQueryCompilingExpressionVisitorDependencies _dependencies;

public InMemoryShapedQueryCompilingExpressionVisitorFactory(IEntityMaterializerSource entityMaterializerSource)
public InMemoryShapedQueryCompilingExpressionVisitorFactory(ShapedQueryCompilingExpressionVisitorDependencies dependencies)
{
_entityMaterializerSource = entityMaterializerSource;
_dependencies = dependencies;
}

public virtual ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
{
return new InMemoryShapedQueryCompilingExpressionVisitor(
queryCompilationContext,
_entityMaterializerSource);
}
=> new InMemoryShapedQueryCompilingExpressionVisitor(queryCompilationContext, _dependencies);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
{
public class InMemoryShapedQueryOptimizer : ShapedQueryOptimizer
{
public InMemoryShapedQueryOptimizer(ShapedQueryOptimizerDependencies dependencies)
: base(dependencies)
{
}

public override Expression Visit(Expression query)
{
query = base.Visit(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
{
public class InMemoryShapedQueryOptimizerFactory : IShapedQueryOptimizerFactory
{
private readonly ShapedQueryOptimizerDependencies _dependencies;

public InMemoryShapedQueryOptimizerFactory(ShapedQueryOptimizerDependencies dependencies)
{
_dependencies = dependencies;
}

public virtual ShapedQueryOptimizer Create(QueryCompilationContext queryCompilationContext)
{
return new InMemoryShapedQueryOptimizer();
return new InMemoryShapedQueryOptimizer(_dependencies);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.EntityFrameworkCore.InMemory.ValueGeneration.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public interface IInMemoryIntegerValueGenerator
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void Bump(object[] row);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,6 @@

namespace Microsoft.EntityFrameworkCore.InMemory.ValueGeneration.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public interface IInMemoryIntegerValueGenerator
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void Bump(object[] row);
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices()
.AddDependencySingleton<SqlExpressionFactoryDependencies>()
.AddDependencySingleton<RelationalMethodCallTranslatorProviderDependencies>()
.AddDependencySingleton<RelationalMemberTranslatorProviderDependencies>()
.AddDependencySingleton<RelationalSqlTranslatingExpressionVisitorFactoryDependencies>()
.AddDependencySingleton<RelationalSqlTranslatingExpressionVisitorDependencies>()
.AddDependencySingleton<RelationalQueryableMethodTranslatingExpressionVisitorDependencies>()
.AddDependencySingleton<SqlExpressionVisitorDependencies>()
.AddDependencySingleton<RelationalShapedQueryCompilingExpressionVisitorDependencies>()
.AddDependencySingleton<RelationalShapedQueryOptimizerDependencies>()
.AddDependencyScoped<MigrationsSqlGeneratorDependencies>()
.AddDependencyScoped<RelationalConventionSetBuilderDependencies>()
.AddDependencyScoped<ModificationCommandBatchFactoryDependencies>()
Expand All @@ -193,6 +197,7 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices()
.AddDependencyScoped<RelationalCompiledQueryCacheKeyGeneratorDependencies>()
.AddDependencyScoped<RelationalConnectionDependencies>()
.AddDependencyScoped<RelationalDatabaseDependencies>()
.AddDependencyScoped<RelationalQueryContextDependencies>()
.AddDependencyScoped<RelationalEvaluatableExpressionFilterDependencies>();

return base.TryAddCoreServices();
Expand Down
18 changes: 4 additions & 14 deletions src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Storage;

namespace Microsoft.EntityFrameworkCore.Query.Internal
{
public class QuerySqlGeneratorFactory : IQuerySqlGeneratorFactory
{
private readonly IRelationalCommandBuilderFactory _commandBuilderFactory;
private readonly ISqlGenerationHelper _sqlGenerationHelper;
private readonly SqlExpressionVisitorDependencies _dependencies;

public QuerySqlGeneratorFactory(
IRelationalCommandBuilderFactory commandBuilderFactory,
ISqlGenerationHelper sqlGenerationHelper)
public QuerySqlGeneratorFactory(SqlExpressionVisitorDependencies dependencies)
{
_commandBuilderFactory = commandBuilderFactory;
_sqlGenerationHelper = sqlGenerationHelper;
_dependencies = dependencies;
}

public virtual QuerySqlGenerator Create()
{
return new QuerySqlGenerator(
_commandBuilderFactory,
_sqlGenerationHelper);
}
=> new QuerySqlGenerator(_dependencies);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal
{
public class RelationalQueryableMethodTranslatingExpressionVisitorFactory : IQueryableMethodTranslatingExpressionVisitorFactory
{
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IRelationalSqlTranslatingExpressionVisitorFactory _relationalSqlTranslatingExpressionVisitorFactory;
private readonly QueryableMethodTranslatingExpressionVisitorDependencies _dependencies;
private readonly RelationalQueryableMethodTranslatingExpressionVisitorDependencies _relationalDependencies;

public RelationalQueryableMethodTranslatingExpressionVisitorFactory(
IRelationalSqlTranslatingExpressionVisitorFactory relationalSqlTranslatingExpressionVisitorFactory,
ISqlExpressionFactory sqlExpressionFactory)
QueryableMethodTranslatingExpressionVisitorDependencies dependencies,
RelationalQueryableMethodTranslatingExpressionVisitorDependencies relationalDependencies)
{
_sqlExpressionFactory = sqlExpressionFactory;
_relationalSqlTranslatingExpressionVisitorFactory = relationalSqlTranslatingExpressionVisitorFactory;
_dependencies = dependencies;
_relationalDependencies = relationalDependencies;
}

public virtual QueryableMethodTranslatingExpressionVisitor Create(IModel model)
{
return new RelationalQueryableMethodTranslatingExpressionVisitor(
model,
_relationalSqlTranslatingExpressionVisitorFactory,
_sqlExpressionFactory);
}
=> new RelationalQueryableMethodTranslatingExpressionVisitor(
_dependencies,
_relationalDependencies,
model);
}
}
Loading