- 修复 2.0.103 Uow.Orm 事务 bug;

This commit is contained in:
2881099 2020-12-07 15:44:12 +08:00
parent 8182238087
commit 32d4f671fe
3 changed files with 9 additions and 4 deletions

View File

@ -27,6 +27,10 @@ namespace aspnetcore_transaction.Controllers
virtual public object Get([FromServices] BaseRepository<Song> repoSong, [FromServices] BaseRepository<Detail> repoDetail, [FromServices] SongRepository repoSong2, virtual public object Get([FromServices] BaseRepository<Song> repoSong, [FromServices] BaseRepository<Detail> repoDetail, [FromServices] SongRepository repoSong2,
[FromServices] SongService serviceSong) [FromServices] SongService serviceSong)
{ {
//repoSong.Insert(new Song());
//repoDetail.Insert(new Detail());
//repoSong2.Insert(new Song());
serviceSong.Test1(); serviceSong.Test1();
return "111"; return "111";
} }

View File

@ -12,8 +12,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
<PackageReference Include="FreeSql.DynamicProxy" Version="1.4.0" /> <PackageReference Include="FreeSql.DynamicProxy" Version="1.5.0" />
<PackageReference Include="IdleBus" Version="1.5.0" /> <PackageReference Include="IdleBus" Version="1.5.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -13,7 +13,8 @@ namespace FreeSql
/// </summary> /// </summary>
public class UnitOfWorkManager : IDisposable public class UnitOfWorkManager : IDisposable
{ {
DbContextScopedFreeSql _ormScoped; internal DbContextScopedFreeSql _ormScoped;
internal IFreeSql OrmOriginal => _ormScoped?._originalFsql;
public IFreeSql Orm => _ormScoped; public IFreeSql Orm => _ormScoped;
List<UowInfo> _rawUows = new List<UowInfo>(); List<UowInfo> _rawUows = new List<UowInfo>();
List<UowInfo> _allUows = new List<UowInfo>(); List<UowInfo> _allUows = new List<UowInfo>();
@ -136,7 +137,7 @@ namespace FreeSql
} }
IUnitOfWork CreateUow(IsolationLevel? isolationLevel) IUnitOfWork CreateUow(IsolationLevel? isolationLevel)
{ {
var uow = new UnitOfWorkOrginal(new UnitOfWork(Orm)); var uow = new UnitOfWorkOrginal(new UnitOfWork(OrmOriginal));
var uowInfo = new UowInfo(uow, UowInfo.UowType.Orginal, false); var uowInfo = new UowInfo(uow, UowInfo.UowType.Orginal, false);
if (isolationLevel != null) uow.IsolationLevel = isolationLevel.Value; if (isolationLevel != null) uow.IsolationLevel = isolationLevel.Value;
try { uow.GetOrBeginTransaction(); } try { uow.GetOrBeginTransaction(); }