From 3b6fee5a89ba8dde1ba75ac931a9ae372081bb45 Mon Sep 17 00:00:00 2001 From: Laurents Meyer Date: Mon, 13 Jun 2022 19:39:33 +0200 Subject: [PATCH] Disable savepoint API, because it is not supported by Jet. (#126) --- .../JetServiceCollectionExtensions.cs | 1 + .../Storage/Internal/JetTransaction.cs | 65 +++++++++++++++++++ .../Storage/Internal/JetTransactionFactory.cs | 19 ++++++ 3 files changed, 85 insertions(+) create mode 100644 src/EFCore.Jet/Storage/Internal/JetTransaction.cs create mode 100644 src/EFCore.Jet/Storage/Internal/JetTransactionFactory.cs diff --git a/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs b/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs index ea745f2..afb4e82 100644 --- a/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs +++ b/src/EFCore.Jet/Extensions/JetServiceCollectionExtensions.cs @@ -61,6 +61,7 @@ namespace Microsoft.Extensions.DependencyInjection .TryAdd() .TryAdd() .TryAdd() + .TryAdd() .TryAddProviderSpecificServices( b => b .TryAddSingleton() diff --git a/src/EFCore.Jet/Storage/Internal/JetTransaction.cs b/src/EFCore.Jet/Storage/Internal/JetTransaction.cs new file mode 100644 index 0000000..2bc1f4a --- /dev/null +++ b/src/EFCore.Jet/Storage/Internal/JetTransaction.cs @@ -0,0 +1,65 @@ +using System; +using System.Data.Common; +using System.Threading; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Storage; + +namespace EntityFrameworkCore.Jet.Storage.Internal +{ + public class JetTransaction : RelationalTransaction + { + /// + public JetTransaction( + [NotNull] IRelationalConnection connection, + [NotNull] DbTransaction transaction, + Guid transactionId, + [NotNull] IDiagnosticsLogger logger, + bool transactionOwned) + : base(connection, transaction, transactionId, logger, transactionOwned) + { + } + + /// + public override bool SupportsSavepoints + => false; + + /// + public override void CreateSavepoint(string name) + => throw new NotSupportedException(); + + /// + public override Task CreateSavepointAsync(string name, CancellationToken cancellationToken = new CancellationToken()) + => throw new NotSupportedException(); + + /// + protected override string GetCreateSavepointSql(string name) + => throw new NotSupportedException(); + + /// + public override void RollbackToSavepoint(string name) + => throw new NotSupportedException(); + + /// + public override Task RollbackToSavepointAsync(string name, CancellationToken cancellationToken = new CancellationToken()) + => throw new NotSupportedException(); + + /// + protected override string GetRollbackToSavepointSql(string name) + => throw new NotSupportedException(); + + /// + public override void ReleaseSavepoint(string name) + => throw new NotSupportedException(); + + /// + public override Task ReleaseSavepointAsync(string name, CancellationToken cancellationToken = default) + => throw new NotSupportedException(); + + /// + protected override string GetReleaseSavepointSql(string name) + => throw new NotSupportedException(); + } +} \ No newline at end of file diff --git a/src/EFCore.Jet/Storage/Internal/JetTransactionFactory.cs b/src/EFCore.Jet/Storage/Internal/JetTransactionFactory.cs new file mode 100644 index 0000000..dfb1401 --- /dev/null +++ b/src/EFCore.Jet/Storage/Internal/JetTransactionFactory.cs @@ -0,0 +1,19 @@ +using System; +using System.Data.Common; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Storage; + +namespace EntityFrameworkCore.Jet.Storage.Internal +{ + public class JetTransactionFactory : IRelationalTransactionFactory + { + public virtual RelationalTransaction Create( + IRelationalConnection connection, + DbTransaction transaction, + Guid transactionId, + IDiagnosticsLogger logger, + bool transactionOwned) + => new JetTransaction(connection, transaction, transactionId, logger, transactionOwned); + } +} \ No newline at end of file