diff --git a/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs b/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs index 36d7538..17bb0c2 100644 --- a/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs +++ b/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs @@ -62,6 +62,7 @@ namespace Microsoft.Extensions.DependencyInjection .TryAdd() .TryAdd() .TryAdd() + .TryAdd() .TryAddProviderSpecificServices( b => b .TryAddSingleton() diff --git a/src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessor.cs b/src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessor.cs new file mode 100644 index 0000000..b406815 --- /dev/null +++ b/src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessor.cs @@ -0,0 +1,66 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Linq.Expressions; +using EntityFrameworkCore.Jet.Query.Internal; +using EntityFrameworkCore.Jet.Utilities; +using Microsoft.EntityFrameworkCore.Query; + +namespace EntityFrameworkCore.Jet.Query.Internal; + +/// +/// 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. +/// +public class JetParameterBasedSqlProcessor : RelationalParameterBasedSqlProcessor +{ + /// + /// 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. + /// + public JetParameterBasedSqlProcessor( + RelationalParameterBasedSqlProcessorDependencies dependencies, + bool useRelationalNulls) + : base(dependencies, useRelationalNulls) + { + } + + /// + /// 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. + /// + public override Expression Optimize( + Expression queryExpression, + IReadOnlyDictionary parametersValues, + out bool canCache) + { + var optimizedQueryExpression = base.Optimize(queryExpression, parametersValues, out canCache); + + /*optimizedQueryExpression = new SkipTakeCollapsingExpressionVisitor(Dependencies.SqlExpressionFactory) + .Process(optimizedQueryExpression, parametersValues, out var canCache2);*/ + + //canCache &= canCache2; + + return new SearchConditionConvertingExpressionVisitor(Dependencies.SqlExpressionFactory).Visit(optimizedQueryExpression); + } + + /// + protected override Expression ProcessSqlNullability( + Expression selectExpression, + IReadOnlyDictionary parametersValues, + out bool canCache) + { + Check.NotNull(selectExpression, nameof(selectExpression)); + Check.NotNull(parametersValues, nameof(parametersValues)); + + return new JetSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process( + selectExpression, parametersValues, out canCache); + } +} diff --git a/src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessorFactory.cs b/src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessorFactory.cs new file mode 100644 index 0000000..8e88239 --- /dev/null +++ b/src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessorFactory.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.Query; + +namespace EntityFrameworkCore.Jet.Query.Internal; + +/// +/// 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. +/// +public class JetParameterBasedSqlProcessorFactory : IRelationalParameterBasedSqlProcessorFactory +{ + /// + /// 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. + /// + public JetParameterBasedSqlProcessorFactory( + RelationalParameterBasedSqlProcessorDependencies dependencies) + { + Dependencies = dependencies; + } + + /// + /// Relational provider-specific dependencies for this service. + /// + protected virtual RelationalParameterBasedSqlProcessorDependencies Dependencies { get; } + + /// + /// 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. + /// + public virtual RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls) + => new JetParameterBasedSqlProcessor(Dependencies, useRelationalNulls); +} diff --git a/src/EFCore.Jet/Query/Internal/JetQueryTranslationPostprocessor.cs b/src/EFCore.Jet/Query/Internal/JetQueryTranslationPostprocessor.cs index 52817e2..de27b69 100644 --- a/src/EFCore.Jet/Query/Internal/JetQueryTranslationPostprocessor.cs +++ b/src/EFCore.Jet/Query/Internal/JetQueryTranslationPostprocessor.cs @@ -27,8 +27,6 @@ namespace EntityFrameworkCore.Jet.Query.Internal public override Expression Process(Expression query) { query = base.Process(query); - - query = new SearchConditionConvertingExpressionVisitor(RelationalDependencies.SqlExpressionFactory).Visit(query); if (_options.EnableMillisecondsSupport) { diff --git a/src/EFCore.Jet/Query/Internal/JetSqlNullabilityProcessor.cs b/src/EFCore.Jet/Query/Internal/JetSqlNullabilityProcessor.cs new file mode 100644 index 0000000..6ac89e0 --- /dev/null +++ b/src/EFCore.Jet/Query/Internal/JetSqlNullabilityProcessor.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; + +namespace EntityFrameworkCore.Jet.Query.Internal; + +/// +/// 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. +/// +public class JetSqlNullabilityProcessor : SqlNullabilityProcessor +{ + /// + /// 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. + /// + public JetSqlNullabilityProcessor( + RelationalParameterBasedSqlProcessorDependencies dependencies, + bool useRelationalNulls) + : base(dependencies, useRelationalNulls) + { + } + + /// + /// 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. + /// + protected override SqlExpression VisitCustomSqlExpression( + SqlExpression sqlExpression, + bool allowOptimizedExpansion, + out bool nullable) + { + return base.VisitCustomSqlExpression(sqlExpression, allowOptimizedExpansion, out nullable); + } +}