Skip to content

Commit

Permalink
v1.6.2 设置映射优先级为 Aop
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Sep 13, 2022
1 parent ad0b5bc commit 90d9557
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/FreeSql.Cloud/FreeSql.Cloud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard20;net40</TargetFrameworks>
<Version>1.6.1</Version>
<Version>1.6.2</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>FreeSql;ncc;YeXiangQin</Authors>
<Description>提供跨数据库访问,分布式事务TCC、SAGA解决方案,支持 .NET Core 2.1+, .NET Framework 4.0+.</Description>
Expand Down
17 changes: 11 additions & 6 deletions src/FreeSql.Cloud/FreeSqlCloud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ public FreeSqlCloud<TDBKey> Register(TDBKey dbkey, Func<IFreeSql> create)
if (!string.IsNullOrWhiteSpace(DistributeKey))
{
var orm = _ib.Get(dbkey);
orm.CodeFirst.ConfigEntity<UnitInvokedInfo>(a => a.Name($"unit_invoked_{DistributeKey}"));
orm.Aop.ConfigEntity += (_, e) =>
{
if (e.EntityType == typeof(UnitInvokedInfo)) e.ModifyResult.Name = $"unit_invoked_{DistributeKey}";
};
orm.CodeFirst.SyncStructure<UnitInvokedInfo>(); //StartTcc(tid).Then<TccUnit1>(DbEnum.db2, null) 幂等判断表

//orm.CodeFirst.ConfigEntity<SagaUnitInvokeInfo>(a => a.Name($"saga_{DistributeKey}_unit_invoke"));
Expand All @@ -128,14 +131,16 @@ public FreeSqlCloud<TDBKey> Register(TDBKey dbkey, Func<IFreeSql> create)
if (_distributeTraceEnable) _distributedTraceCall($"{dbkey} 注册成功, 并存储 TCC/SAGA 事务相关数据");
_scheduler = new FreeScheduler.Scheduler(new FreeScheduler.TaskHandlers.TestHandler());

_ormMaster.CodeFirst.ConfigEntity<TccMasterInfo>(a => a.Name($"tcc_{DistributeKey}"));
_ormMaster.Aop.ConfigEntity += (_, e) =>
{
if (e.EntityType == typeof(TccMasterInfo)) e.ModifyResult.Name = $"tcc_{DistributeKey}";
if (e.EntityType == typeof(TccUnitInfo)) e.ModifyResult.Name = $"tcc_{DistributeKey}_unit";
if (e.EntityType == typeof(SagaMasterInfo)) e.ModifyResult.Name = $"saga_{DistributeKey}";
if (e.EntityType == typeof(SagaUnitInfo)) e.ModifyResult.Name = $"saga_{DistributeKey}_unit";
};
_ormMaster.CodeFirst.SyncStructure<TccMasterInfo>();
_ormMaster.CodeFirst.ConfigEntity<TccUnitInfo>(a => a.Name($"tcc_{DistributeKey}_unit"));
_ormMaster.CodeFirst.SyncStructure<TccUnitInfo>();

_ormMaster.CodeFirst.ConfigEntity<SagaMasterInfo>(a => a.Name($"saga_{DistributeKey}"));
_ormMaster.CodeFirst.SyncStructure<SagaMasterInfo>();
_ormMaster.CodeFirst.ConfigEntity<SagaUnitInfo>(a => a.Name($"saga_{DistributeKey}_unit"));
_ormMaster.CodeFirst.SyncStructure<SagaUnitInfo>();

#region 加载历史未未成 TCC 事务
Expand Down

0 comments on commit 90d9557

Please sign in to comment.