From 3fc05989f3cfc90a8ffebdc44717ff2d3ae76efd Mon Sep 17 00:00:00 2001 From: thisispaulsmith Date: Wed, 12 May 2021 16:23:18 +0100 Subject: [PATCH] Implement IInfrastructure` on CapEFDbTransaction (#868) Co-authored-by: Paul Smith --- .../IDbContextTransaction.CAP.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/DotNetCore.CAP.SqlServer/IDbContextTransaction.CAP.cs b/src/DotNetCore.CAP.SqlServer/IDbContextTransaction.CAP.cs index e476bb0..cbeb745 100644 --- a/src/DotNetCore.CAP.SqlServer/IDbContextTransaction.CAP.cs +++ b/src/DotNetCore.CAP.SqlServer/IDbContextTransaction.CAP.cs @@ -2,21 +2,23 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; +using System.Data.Common; using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP; +using Microsoft.EntityFrameworkCore.Infrastructure; // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.Storage { - internal class CapEFDbTransaction : IDbContextTransaction + internal class CapEFDbTransaction : IDbContextTransaction, IInfrastructure { private readonly ICapTransaction _transaction; public CapEFDbTransaction(ICapTransaction transaction) { _transaction = transaction; - var dbContextTransaction = (IDbContextTransaction) _transaction.DbTransaction; + var dbContextTransaction = (IDbContextTransaction)_transaction.DbTransaction; TransactionId = dbContextTransaction.TransactionId; } @@ -51,5 +53,14 @@ namespace Microsoft.EntityFrameworkCore.Storage { return new ValueTask(Task.Run(() => _transaction.Dispose())); } + + public DbTransaction Instance + { + get + { + var dbContextTransaction = (IDbContextTransaction)_transaction.DbTransaction; + return dbContextTransaction.GetDbTransaction(); + } + } } } \ No newline at end of file