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)); } } }