|
|
|
@ -1,11 +1,15 @@
|
|
|
|
using System.Data;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Data;
|
|
|
|
using System.Data.Common;
|
|
|
|
using System.Data.Common;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace EntityFrameworkCore.Jet.Data
|
|
|
|
namespace EntityFrameworkCore.Jet.Data
|
|
|
|
{
|
|
|
|
{
|
|
|
|
internal class JetTransaction : DbTransaction
|
|
|
|
internal class JetTransaction : DbTransaction
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly JetConnection _connection;
|
|
|
|
private JetConnection _connection;
|
|
|
|
|
|
|
|
private bool _disposed;
|
|
|
|
|
|
|
|
|
|
|
|
internal virtual DbTransaction WrappedTransaction { get; }
|
|
|
|
internal virtual DbTransaction WrappedTransaction { get; }
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,8 +26,12 @@ namespace EntityFrameworkCore.Jet.Data
|
|
|
|
|
|
|
|
|
|
|
|
public override void Commit()
|
|
|
|
public override void Commit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_disposed)
|
|
|
|
|
|
|
|
throw new ObjectDisposedException(nameof(JetTransaction));
|
|
|
|
|
|
|
|
|
|
|
|
LogHelper.ShowCommandHeader("--- Commit");
|
|
|
|
LogHelper.ShowCommandHeader("--- Commit");
|
|
|
|
WrappedTransaction.Commit();
|
|
|
|
WrappedTransaction.Commit();
|
|
|
|
|
|
|
|
|
|
|
|
_connection.ActiveTransaction = null;
|
|
|
|
_connection.ActiveTransaction = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -35,9 +43,63 @@ namespace EntityFrameworkCore.Jet.Data
|
|
|
|
|
|
|
|
|
|
|
|
public override void Rollback()
|
|
|
|
public override void Rollback()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_disposed)
|
|
|
|
|
|
|
|
throw new ObjectDisposedException(nameof(JetTransaction));
|
|
|
|
|
|
|
|
|
|
|
|
LogHelper.ShowCommandHeader("^^^ Rollback");
|
|
|
|
LogHelper.ShowCommandHeader("^^^ Rollback");
|
|
|
|
WrappedTransaction.Rollback();
|
|
|
|
WrappedTransaction.Rollback();
|
|
|
|
|
|
|
|
|
|
|
|
_connection.ActiveTransaction = null;
|
|
|
|
_connection.ActiveTransaction = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (disposing)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_connection?.ActiveTransaction == this)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Connection.State == ConnectionState.Open)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Rollback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_connection.ActiveTransaction = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_disposed = true;
|
|
|
|
|
|
|
|
_connection = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Task CommitAsync(CancellationToken cancellationToken = new CancellationToken())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_disposed)
|
|
|
|
|
|
|
|
throw new ObjectDisposedException(nameof(JetTransaction));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return base.CommitAsync(cancellationToken);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override ValueTask DisposeAsync()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_disposed)
|
|
|
|
|
|
|
|
throw new ObjectDisposedException(nameof(JetTransaction));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return base.DisposeAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Task RollbackAsync(CancellationToken cancellationToken = new CancellationToken())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_disposed)
|
|
|
|
|
|
|
|
throw new ObjectDisposedException(nameof(JetTransaction));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return base.RollbackAsync(cancellationToken);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|