From c80d05fe6e61352d4841382e02b75ffdacb70dd6 Mon Sep 17 00:00:00 2001
From: Coldairarrow <862520575@qq.com>
Date: Wed, 29 Apr 2020 22:02:23 +0800
Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=88=A0=E9=99=A4=E5=BC=82?=
=?UTF-8?q?=E5=B8=B8=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Coldairarrow.Util/01.Coldairarrow.Util.csproj | 2 +-
src/Coldairarrow.Util/AOP/TransactionalAttribute.cs | 13 +++++++++----
src/Coldairarrow.Util/GlobalData.cs | 5 +----
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/Coldairarrow.Util/01.Coldairarrow.Util.csproj b/src/Coldairarrow.Util/01.Coldairarrow.Util.csproj
index bd96919e..82ee4335 100644
--- a/src/Coldairarrow.Util/01.Coldairarrow.Util.csproj
+++ b/src/Coldairarrow.Util/01.Coldairarrow.Util.csproj
@@ -32,7 +32,7 @@
-
+
diff --git a/src/Coldairarrow.Util/AOP/TransactionalAttribute.cs b/src/Coldairarrow.Util/AOP/TransactionalAttribute.cs
index bce3ca89..e1bf5fc4 100644
--- a/src/Coldairarrow.Util/AOP/TransactionalAttribute.cs
+++ b/src/Coldairarrow.Util/AOP/TransactionalAttribute.cs
@@ -45,10 +45,15 @@ public TransactionContainer(IServiceProvider serviceProvider)
{
_distributedTransaction = DistributedTransactionFactory.GetDistributedTransaction();
- var repositories = GlobalData.AllFxTypes.Where(x =>
- typeof(IRepository).IsAssignableFrom(x)
- && x.IsInterface
- ).Select(x => serviceProvider.GetService(x) as IRepository)
+ var allRepositoryInterfaces = GlobalData.AllFxTypes.Where(x =>
+ typeof(IRepository).IsAssignableFrom(x)
+ && x.IsInterface
+ && x != typeof(IRepository)
+ ).ToList();
+ allRepositoryInterfaces.Add(typeof(IRepository));
+
+ var repositories = allRepositoryInterfaces
+ .Select(x => serviceProvider.GetService(x) as IRepository)
.ToArray();
_distributedTransaction.AddRepository(repositories);
diff --git a/src/Coldairarrow.Util/GlobalData.cs b/src/Coldairarrow.Util/GlobalData.cs
index 902e19f8..36e4e3d1 100644
--- a/src/Coldairarrow.Util/GlobalData.cs
+++ b/src/Coldairarrow.Util/GlobalData.cs
@@ -1,5 +1,4 @@
-using EFCore.Sharding;
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -45,8 +44,6 @@ public static List AllFxTypes
}
});
-
- _allFxTypes.Add(typeof(IRepository));
}
}
}