From 690380a3cc244306f8aff6e803ef959b39aed149 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Fri, 17 Aug 2018 18:20:37 +0800 Subject: [PATCH] tweak transaction extension method --- src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs b/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs index e0a0054..fc7b1a6 100644 --- a/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs +++ b/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs @@ -45,6 +45,11 @@ namespace DotNetCore.CAP public static ICapTransaction Begin(this ICapTransaction transaction, IClientSessionHandle dbTransaction, bool autoCommit = false) { + if (!dbTransaction.IsInTransaction) + { + dbTransaction.StartTransaction(); + } + transaction.DbTransaction = dbTransaction; transaction.AutoCommit = autoCommit;