Skip to content

Commit

Permalink
Move more implementation up with default interface implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Apr 22, 2020
1 parent b4703a7 commit 946a2da
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 42 deletions.
26 changes: 0 additions & 26 deletions src/EFCore.Relational/Storage/RelationalTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,32 +270,6 @@ await Logger.TransactionErrorAsync(
await ClearTransactionAsync(cancellationToken);
}

/// <inheritdoc />
public virtual void Save(string savepointName)
=> throw new NotSupportedException();

/// <inheritdoc />
public virtual Task SaveAsync(string savepointName, CancellationToken cancellationToken = default)
=> throw new NotSupportedException();

/// <inheritdoc />
public virtual void Rollback(string savepointName)
=> throw new NotSupportedException();

/// <inheritdoc />
public virtual Task RollbackAsync(string savepointName, CancellationToken cancellationToken = default)
=> throw new NotSupportedException();

/// <inheritdoc />
public virtual void Release(string savepointName) { }

/// <inheritdoc />
public virtual Task ReleaseAsync(string savepointName, CancellationToken cancellationToken = default)
=> Task.CompletedTask;

/// <inheritdoc />
public virtual bool AreSavepointsSupported => false;

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal
{
public class SqlServerTransaction : RelationalTransaction
public class SqlServerTransaction : RelationalTransaction, IDbContextTransaction
{
private readonly DbTransaction _dbTransaction;

Expand All @@ -31,7 +31,7 @@ public SqlServerTransaction(
=> _dbTransaction = transaction;

/// <inheritdoc />
public override void Save(string savepointName)
public void Save(string savepointName)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -40,7 +40,7 @@ public override void Save(string savepointName)
}

/// <inheritdoc />
public override async Task SaveAsync(string savepointName, CancellationToken cancellationToken = default)
public async Task SaveAsync(string savepointName, CancellationToken cancellationToken = default)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -49,7 +49,7 @@ public override async Task SaveAsync(string savepointName, CancellationToken can
}

/// <inheritdoc />
public override void Rollback(string savepointName)
public void Rollback(string savepointName)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -58,7 +58,7 @@ public override void Rollback(string savepointName)
}

/// <inheritdoc />
public override async Task RollbackAsync(string savepointName, CancellationToken cancellationToken = default)
public async Task RollbackAsync(string savepointName, CancellationToken cancellationToken = default)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -67,6 +67,6 @@ public override async Task RollbackAsync(string savepointName, CancellationToken
}

/// <inheritdoc />
public override bool AreSavepointsSupported => true;
public bool AreSavepointsSupported => true;
}
}
16 changes: 8 additions & 8 deletions src/EFCore.Sqlite.Core/Storage/Internal/SqliteTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal
{
public class SqliteTransaction : RelationalTransaction
public class SqliteTransaction : RelationalTransaction, IDbContextTransaction
{
private readonly DbTransaction _dbTransaction;

Expand All @@ -31,7 +31,7 @@ public SqliteTransaction(
=> _dbTransaction = transaction;

/// <inheritdoc />
public override void Save(string savepointName)
public void Save(string savepointName)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -40,7 +40,7 @@ public override void Save(string savepointName)
}

/// <inheritdoc />
public override async Task SaveAsync(string savepointName, CancellationToken cancellationToken = default)
public async Task SaveAsync(string savepointName, CancellationToken cancellationToken = default)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -49,7 +49,7 @@ public override async Task SaveAsync(string savepointName, CancellationToken can
}

/// <inheritdoc />
public override void Rollback(string savepointName)
public void Rollback(string savepointName)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -58,7 +58,7 @@ public override void Rollback(string savepointName)
}

/// <inheritdoc />
public override async Task RollbackAsync(string savepointName, CancellationToken cancellationToken = default)
public async Task RollbackAsync(string savepointName, CancellationToken cancellationToken = default)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -67,7 +67,7 @@ public override async Task RollbackAsync(string savepointName, CancellationToken
}

/// <inheritdoc />
public override void Release(string savepointName)
public void Release(string savepointName)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -76,7 +76,7 @@ public override void Release(string savepointName)
}

/// <inheritdoc />
public override async Task ReleaseAsync(string savepointName, CancellationToken cancellationToken = default)
public async Task ReleaseAsync(string savepointName, CancellationToken cancellationToken = default)
{
using var command = Connection.DbConnection.CreateCommand();
command.Transaction = _dbTransaction;
Expand All @@ -85,6 +85,6 @@ public override async Task ReleaseAsync(string savepointName, CancellationToken
}

/// <inheritdoc />
public override bool AreSavepointsSupported => true;
public bool AreSavepointsSupported => true;
}
}
4 changes: 2 additions & 2 deletions src/EFCore/Storage/IDbContextTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Task RollbackAsync([NotNull] string savepointName, CancellationToken cancellatio
/// reclaim some resources before the transaction ends.
/// </summary>
/// <param name="savepointName"> The name of the savepoint to release. </param>
void Release([NotNull] string savepointName) => throw new NotSupportedException();
void Release([NotNull] string savepointName) { }

/// <summary>
/// Destroys a savepoint previously defined in the current transaction. This allows the system to
Expand All @@ -98,7 +98,7 @@ Task RollbackAsync([NotNull] string savepointName, CancellationToken cancellatio
/// <param name="cancellationToken"> The cancellation token. </param>
/// <returns> A <see cref="Task" /> representing the asynchronous operation. </returns>
Task ReleaseAsync([NotNull] string savepointName, CancellationToken cancellationToken = default)
=> throw new NotSupportedException();
=> Task.CompletedTask;

/// <summary>
/// Gets a value that indicates whether this <see cref="IDbContextTransaction"/> instance supports
Expand Down

0 comments on commit 946a2da

Please sign in to comment.