Upgrade sql update generation files to 3.1.x.

pull/41/head
Lau 6 years ago
parent 6e8cc34c72
commit 70f2b880ca

@ -1,15 +1,21 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Update; using Microsoft.EntityFrameworkCore.Update;
namespace EntityFrameworkCore.Jet.Update.Internal namespace EntityFrameworkCore.Jet.Update.Internal
{ {
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// <para>
/// directly from your code. This API may change or be removed in future releases. /// 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.
/// </para>
/// <para>
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
/// is used by many <see cref="DbContext" /> instances. The implementation must be thread-safe.
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
/// </para>
/// </summary> /// </summary>
public interface IJetUpdateSqlGenerator : IUpdateSqlGenerator public interface IJetUpdateSqlGenerator : IUpdateSqlGenerator
{ {

@ -1,68 +1,59 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Update; using Microsoft.EntityFrameworkCore.Update;
namespace EntityFrameworkCore.Jet.Update.Internal namespace EntityFrameworkCore.Jet.Update.Internal
{ {
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
public class JetModificationCommandBatch : AffectedCountModificationCommandBatch public class JetModificationCommandBatch : AffectedCountModificationCommandBatch
{ {
private int _parameterCount = 1; // Implicit parameter for the command text private const int MaxRowCount = 1;
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
public JetModificationCommandBatch( public JetModificationCommandBatch(
[NotNull] IRelationalCommandBuilderFactory commandBuilderFactory, [NotNull] ModificationCommandBatchFactoryDependencies dependencies)
[NotNull] ISqlGenerationHelper sqlGenerationHelper, : base(dependencies)
// ReSharper disable once SuggestBaseTypeForParameter
[NotNull] IJetUpdateSqlGenerator updateSqlGenerator,
[NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
: base(
commandBuilderFactory,
sqlGenerationHelper,
updateSqlGenerator,
valueBufferFactoryFactory)
{ {
// See https://support.office.com/en-us/article/access-specifications-0cf3c66f-9cf2-4e32-9568-98c1025bb47c
// for Access specifications and limits.
} }
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// </summary> /// any release. You should only use it directly in your code with extreme caution and knowing that
protected new virtual IJetUpdateSqlGenerator UpdateSqlGenerator => (IJetUpdateSqlGenerator)base.UpdateSqlGenerator; /// doing so can result in application failures when updating to a new Entity Framework Core release.
/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary> /// </summary>
protected override bool CanAddCommand(ModificationCommand modificationCommand) protected override bool CanAddCommand(ModificationCommand modificationCommand)
{ => ModificationCommands.Count < MaxRowCount;
return ModificationCommands.Count == 0;
}
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
protected override bool IsCommandTextValid() protected override bool IsCommandTextValid()
{ => true;
return true;
}
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
protected override int GetParameterCount() protected override int GetParameterCount()
=> _parameterCount; => 1;
} }
} }

@ -1,64 +1,53 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
using EntityFrameworkCore.Jet.Infrastructure.Internal;
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Update; using Microsoft.EntityFrameworkCore.Update;
using EntityFrameworkCore.Jet.Utilities; using EntityFrameworkCore.Jet.Utilities;
namespace EntityFrameworkCore.Jet.Update.Internal namespace EntityFrameworkCore.Jet.Update.Internal
{ {
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// <para>
/// directly from your code. This API may change or be removed in future releases. /// 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.
/// </para>
/// <para>
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
/// <see cref="DbContext" /> instance will use its own instance of this service.
/// The implementation may depend on other services registered with any lifetime.
/// The implementation does not need to be thread-safe.
/// </para>
/// </summary> /// </summary>
public class JetModificationCommandBatchFactory : IModificationCommandBatchFactory public class JetModificationCommandBatchFactory : IModificationCommandBatchFactory
{ {
private readonly IRelationalCommandBuilderFactory _commandBuilderFactory; private readonly ModificationCommandBatchFactoryDependencies _dependencies;
private readonly ISqlGenerationHelper _sqlGenerationHelper;
private readonly IJetUpdateSqlGenerator _updateSqlGenerator;
private readonly IRelationalValueBufferFactoryFactory _valueBufferFactoryFactory;
private readonly IDbContextOptions _options;
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
public JetModificationCommandBatchFactory( public JetModificationCommandBatchFactory(
[NotNull] IRelationalCommandBuilderFactory commandBuilderFactory, [NotNull] ModificationCommandBatchFactoryDependencies dependencies,
[NotNull] ISqlGenerationHelper sqlGenerationHelper,
[NotNull] IJetUpdateSqlGenerator updateSqlGenerator,
[NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
[NotNull] IDbContextOptions options) [NotNull] IDbContextOptions options)
{ {
Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory)); Check.NotNull(dependencies, nameof(dependencies));
Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
Check.NotNull(options, nameof(options)); Check.NotNull(options, nameof(options));
_commandBuilderFactory = commandBuilderFactory; _dependencies = dependencies;
_sqlGenerationHelper = sqlGenerationHelper;
_updateSqlGenerator = updateSqlGenerator;
_valueBufferFactoryFactory = valueBufferFactoryFactory;
_options = options;
} }
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
public virtual ModificationCommandBatch Create() public virtual ModificationCommandBatch Create()
{ => new JetModificationCommandBatch(_dependencies);
var optionsExtension = _options.Extensions.OfType<JetOptionsExtension>().FirstOrDefault();
return new JetModificationCommandBatch(
_commandBuilderFactory,
_sqlGenerationHelper,
_updateSqlGenerator,
_valueBufferFactoryFactory);
}
} }
} }

@ -1,6 +1,5 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Text; using System.Text;
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Update; using Microsoft.EntityFrameworkCore.Update;
@ -8,8 +7,17 @@ using Microsoft.EntityFrameworkCore.Update;
namespace EntityFrameworkCore.Jet.Update.Internal namespace EntityFrameworkCore.Jet.Update.Internal
{ {
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// <para>
/// directly from your code. This API may change or be removed in future releases. /// 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.
/// </para>
/// <para>
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
/// is used by many <see cref="DbContext" /> instances. The implementation must be thread-safe.
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />.
/// </para>
/// </summary> /// </summary>
public class JetUpdateSqlGenerator : UpdateSqlGenerator, IJetUpdateSqlGenerator public class JetUpdateSqlGenerator : UpdateSqlGenerator, IJetUpdateSqlGenerator
{ {
@ -20,8 +28,10 @@ namespace EntityFrameworkCore.Jet.Update.Internal
} }
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification) protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification)
{ {
@ -32,11 +42,18 @@ namespace EntityFrameworkCore.Jet.Update.Internal
} }
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// 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> /// </summary>
protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected) protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected)
{ {
// TODO: Implement translation of @@ROWCOUNT related queries into System.Data.Jet.
// Every the AffectedRecords of every NonQueryExecution needs to be saved per connection,
// so it can be replaced in later queries if needed.
// Other executions should set this saved value just to 0.
// Jet does not support ROWCOUNT // Jet does not support ROWCOUNT
// Here we really hope that ROWCOUNT is not required // Here we really hope that ROWCOUNT is not required
// Actually, RecordsAffected is handled by JetModificationCommandBatch // Actually, RecordsAffected is handled by JetModificationCommandBatch
@ -52,9 +69,11 @@ namespace EntityFrameworkCore.Jet.Update.Internal
} }
/// <summary> /// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// directly from your code. This API may change or be removed in future releases. /// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// </summary> /// 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>rom your code. This API may change or be removed in future releases.
protected override ResultSetMapping AppendSelectAffectedCountCommand(StringBuilder commandStringBuilder, string name, string schema, int commandPosition) protected override ResultSetMapping AppendSelectAffectedCountCommand(StringBuilder commandStringBuilder, string name, string schema, int commandPosition)
{ {
commandStringBuilder commandStringBuilder
@ -64,6 +83,5 @@ namespace EntityFrameworkCore.Jet.Update.Internal
return ResultSetMapping.LastInResultSet; return ResultSetMapping.LastInResultSet;
} }
} }
} }

Loading…
Cancel
Save