From 8b682ca4edd4285c5c0470f5777eca91ffb9aaed Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Sat, 6 Jun 2020 12:07:22 +1200 Subject: [PATCH] Refactor Removed unnecessary usings Renamed extension method classes causing naming conflicts with MS classes --- src/EFCore.Temporal.Query/AsOfQuerySqlGeneratorFactory.cs | 8 +------- .../AsOfQueryableMethodTranslatingExpressionVisitor.cs | 5 ++--- src/EFCore.Temporal.Query/AsOfSqlExpressionFactory.cs | 2 +- src/EFCore.Temporal.Query/AsOfTableExpression.cs | 3 +-- ...ons.cs => SqlServerAsOfEntityTypeBuilderExtensions.cs} | 2 +- ...eExtensions.cs => SqlServerAsOfQueryableExtensions.cs} | 4 ++-- 6 files changed, 8 insertions(+), 16 deletions(-) rename src/EFCore.Temporal.Query/Extensions/{SqlServerEntityTypeBuilderExtensions.cs => SqlServerAsOfEntityTypeBuilderExtensions.cs} (96%) rename src/EFCore.Temporal.Query/Extensions/{SqlServerQueryableExtensions.cs => SqlServerAsOfQueryableExtensions.cs} (87%) diff --git a/src/EFCore.Temporal.Query/AsOfQuerySqlGeneratorFactory.cs b/src/EFCore.Temporal.Query/AsOfQuerySqlGeneratorFactory.cs index 9677e76..051fd62 100644 --- a/src/EFCore.Temporal.Query/AsOfQuerySqlGeneratorFactory.cs +++ b/src/EFCore.Temporal.Query/AsOfQuerySqlGeneratorFactory.cs @@ -1,22 +1,16 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal; namespace EntityFrameworkCore.TemporalTables.Query { public class AsOfQuerySqlGeneratorFactory : IQuerySqlGeneratorFactory { - private readonly IQueryableMethodTranslatingExpressionVisitorFactory _ss; private readonly QuerySqlGeneratorDependencies _dependencies; - private readonly ISqlServerOptions _sqlServerOptions; - private readonly QueryCompilationContext _queryCompilationContext; public AsOfQuerySqlGeneratorFactory( - [NotNull] QuerySqlGeneratorDependencies dependencies, - [NotNull] ISqlServerOptions sqlServerOptions) + [NotNull] QuerySqlGeneratorDependencies dependencies) { _dependencies = dependencies; - _sqlServerOptions = sqlServerOptions; } public QuerySqlGenerator Create() diff --git a/src/EFCore.Temporal.Query/AsOfQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Temporal.Query/AsOfQueryableMethodTranslatingExpressionVisitor.cs index 65346e1..7789ae8 100644 --- a/src/EFCore.Temporal.Query/AsOfQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Temporal.Query/AsOfQueryableMethodTranslatingExpressionVisitor.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Temporal.Query.Extensions.Internal; -using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; namespace EntityFrameworkCore.TemporalTables.Query @@ -62,11 +61,11 @@ protected override QueryableMethodTranslatingExpressionVisitor CreateSubqueryVis protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - if (methodCallExpression.Method.DeclaringType == typeof(SqlServerQueryableExtensions)) + if (methodCallExpression.Method.DeclaringType == typeof(SqlServerAsOfQueryableExtensions)) { switch (methodCallExpression.Method.Name) { - case nameof(SqlServerQueryableExtensions.AsOf): + case nameof(SqlServerAsOfQueryableExtensions.AsOf): // capture the date parameter for use by all AsOfTableExpression instances _asOfDateParameter = Visit(methodCallExpression.Arguments[1]) as ParameterExpression; return Visit(methodCallExpression.Arguments[0]); diff --git a/src/EFCore.Temporal.Query/AsOfSqlExpressionFactory.cs b/src/EFCore.Temporal.Query/AsOfSqlExpressionFactory.cs index f2b76f5..ca25442 100644 --- a/src/EFCore.Temporal.Query/AsOfSqlExpressionFactory.cs +++ b/src/EFCore.Temporal.Query/AsOfSqlExpressionFactory.cs @@ -15,7 +15,7 @@ public AsOfSqlExpressionFactory(SqlExpressionFactoryDependencies dependencies) : public override SelectExpression Select(IEntityType entityType) { - if (entityType.FindAnnotation(SqlServerEntityTypeBuilderExtensions.ANNOTATION_TEMPORAL) != null) + if (entityType.FindAnnotation(SqlServerAsOfEntityTypeBuilderExtensions.ANNOTATION_TEMPORAL) != null) { var asOfTableExpression = new AsOfTableExpression( entityType.GetTableName(), diff --git a/src/EFCore.Temporal.Query/AsOfTableExpression.cs b/src/EFCore.Temporal.Query/AsOfTableExpression.cs index 9b94105..cfca0af 100644 --- a/src/EFCore.Temporal.Query/AsOfTableExpression.cs +++ b/src/EFCore.Temporal.Query/AsOfTableExpression.cs @@ -1,5 +1,4 @@ -using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using System; using System.Linq.Expressions; diff --git a/src/EFCore.Temporal.Query/Extensions/SqlServerEntityTypeBuilderExtensions.cs b/src/EFCore.Temporal.Query/Extensions/SqlServerAsOfEntityTypeBuilderExtensions.cs similarity index 96% rename from src/EFCore.Temporal.Query/Extensions/SqlServerEntityTypeBuilderExtensions.cs rename to src/EFCore.Temporal.Query/Extensions/SqlServerAsOfEntityTypeBuilderExtensions.cs index 4cda69c..7c1b428 100644 --- a/src/EFCore.Temporal.Query/Extensions/SqlServerEntityTypeBuilderExtensions.cs +++ b/src/EFCore.Temporal.Query/Extensions/SqlServerAsOfEntityTypeBuilderExtensions.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore { - public static class SqlServerEntityTypeBuilderExtensions + public static class SqlServerAsOfEntityTypeBuilderExtensions { public static string ANNOTATION_TEMPORAL = "IS_TEMPORAL_TABLE"; diff --git a/src/EFCore.Temporal.Query/Extensions/SqlServerQueryableExtensions.cs b/src/EFCore.Temporal.Query/Extensions/SqlServerAsOfQueryableExtensions.cs similarity index 87% rename from src/EFCore.Temporal.Query/Extensions/SqlServerQueryableExtensions.cs rename to src/EFCore.Temporal.Query/Extensions/SqlServerAsOfQueryableExtensions.cs index 6e25631..57d970c 100644 --- a/src/EFCore.Temporal.Query/Extensions/SqlServerQueryableExtensions.cs +++ b/src/EFCore.Temporal.Query/Extensions/SqlServerAsOfQueryableExtensions.cs @@ -7,10 +7,10 @@ namespace Microsoft.EntityFrameworkCore { - public static class SqlServerQueryableExtensions + public static class SqlServerAsOfQueryableExtensions { public static readonly MethodInfo AsOfMethodInfo - = typeof(SqlServerQueryableExtensions).GetTypeInfo().GetDeclaredMethod(nameof(AsOf)); + = typeof(SqlServerAsOfQueryableExtensions).GetTypeInfo().GetDeclaredMethod(nameof(AsOf)); /// /// Configure a query to constrain all temporal tables to a specific time