-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(efcore): support DB transactions
- Loading branch information
Showing
7 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Expressions.EntityFrameworkCore/Sessions/EfDbSessionTransaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Raiqub.Expressions.Sessions; | ||
|
||
namespace Raiqub.Expressions.EntityFrameworkCore.Sessions; | ||
|
||
public sealed class EfDbSessionTransaction : IDbSessionTransaction | ||
{ | ||
private readonly IDbContextTransaction _contextTransaction; | ||
|
||
public EfDbSessionTransaction(IDbContextTransaction contextTransaction) => | ||
_contextTransaction = contextTransaction; | ||
|
||
public Task CommitAsync(CancellationToken cancellationToken = default) => | ||
_contextTransaction.CommitAsync(cancellationToken); | ||
|
||
public ValueTask DisposeAsync() => | ||
_contextTransaction.DisposeAsync(); | ||
|
||
public void Dispose() => | ||
_contextTransaction.Dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Raiqub.Expressions.Sessions; | ||
|
||
public interface IDbSessionTransaction : IAsyncDisposable, IDisposable | ||
{ | ||
/// <summary>Commits all changes made to the database in the current transaction.</summary> | ||
/// <param name="cancellationToken">A token to observe for cancellation requests.</param> | ||
/// <returns>A <see cref="Task"/> that represents the asynchronous operation.</returns> | ||
Task CommitAsync(CancellationToken cancellationToken = default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters