Skip to content

Commit

Permalink
逻辑删除异常修复
Browse files Browse the repository at this point in the history
  • Loading branch information
Coldairarrow committed Apr 29, 2020
1 parent 2a12542 commit c80d05f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Coldairarrow.Util/01.Coldairarrow.Util.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="Caching.CSRedis" Version="3.6.2" />
<PackageReference Include="CSRedisCore" Version="3.6.2" />
<PackageReference Include="EFCore.Sharding" Version="3.1.3.36" />
<PackageReference Include="EFCore.Sharding" Version="3.1.3.39" />
<PackageReference Include="EFCore.Sharding.SqlServer" Version="3.1.3" />
<PackageReference Include="IdHelper.Zookeeper" Version="1.5.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
Expand Down
13 changes: 9 additions & 4 deletions src/Coldairarrow.Util/AOP/TransactionalAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions src/Coldairarrow.Util/GlobalData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EFCore.Sharding;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -45,8 +44,6 @@ public static List<Type> AllFxTypes

}
});

_allFxTypes.Add(typeof(IRepository));
}
}
}
Expand Down

0 comments on commit c80d05f

Please sign in to comment.