Browse Source

Implement IInfrastructure` on CapEFDbTransaction (#868)

Co-authored-by: Paul Smith <paulsmith@e-qualitylearning.com>
master
thisispaulsmith 3 years ago
committed by GitHub
parent
commit
3fc05989f3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      src/DotNetCore.CAP.SqlServer/IDbContextTransaction.CAP.cs

+ 13
- 2
src/DotNetCore.CAP.SqlServer/IDbContextTransaction.CAP.cs View File

@@ -2,21 +2,23 @@
// Licensed under the MIT License. See License.txt in the project root for license information. // Licensed under the MIT License. See License.txt in the project root for license information.


using System; using System;
using System.Data.Common;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using DotNetCore.CAP; using DotNetCore.CAP;
using Microsoft.EntityFrameworkCore.Infrastructure;


// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Storage namespace Microsoft.EntityFrameworkCore.Storage
{ {
internal class CapEFDbTransaction : IDbContextTransaction
internal class CapEFDbTransaction : IDbContextTransaction, IInfrastructure<DbTransaction>
{ {
private readonly ICapTransaction _transaction; private readonly ICapTransaction _transaction;


public CapEFDbTransaction(ICapTransaction transaction) public CapEFDbTransaction(ICapTransaction transaction)
{ {
_transaction = transaction; _transaction = transaction;
var dbContextTransaction = (IDbContextTransaction) _transaction.DbTransaction;
var dbContextTransaction = (IDbContextTransaction)_transaction.DbTransaction;
TransactionId = dbContextTransaction.TransactionId; TransactionId = dbContextTransaction.TransactionId;
} }


@@ -51,5 +53,14 @@ namespace Microsoft.EntityFrameworkCore.Storage
{ {
return new ValueTask(Task.Run(() => _transaction.Dispose())); return new ValueTask(Task.Run(() => _transaction.Dispose()));
} }

public DbTransaction Instance
{
get
{
var dbContextTransaction = (IDbContextTransaction)_transaction.DbTransaction;
return dbContextTransaction.GetDbTransaction();
}
}
} }
} }

Loading…
Cancel
Save