Skip to content

Commit

Permalink
v1.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Nov 10, 2023
1 parent 5e6b615 commit 3ef961a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fsql.Use(DbEnum.db2).Select<T>();
using (fsql.Change(DbEnum.db2)) {
//todo..
}
//FreeSql.Cloud v1.6.7 一个范围内切换,之后再切换回去
//FreeSql.Cloud v1.6.8 一个范围内切换,之后再切换回去
```

自动定向数据库配置:
Expand Down
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.7</Version>
<Version>1.6.8</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>FreeSql;ncc;YeXiangQin</Authors>
<Description>提供跨数据库访问,分布式事务TCC、SAGA解决方案,支持 .NET Core 2.1+, .NET Framework 4.0+.</Description>
Expand Down
4 changes: 2 additions & 2 deletions src/FreeSql.Cloud/FreeSqlCloud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public IFreeSql Change(TDBKey dbkey)
var oldkey = _dbkeyCurrent.Value;
if (_distributeTraceEnable && object.Equals(dbkey, oldkey) == false) _distributedTraceCall($"数据库切换[Change] {oldkey} -> {dbkey}");
_dbkeyCurrent.Value = dbkey;
return new FreeSqlCloundSnapshot<TDBKey>(this, dbkey, oldkey);
return new FreeSqlCloundSnapshot<TDBKey>(this, dbkey, () => _dbkeyCurrent.Value = oldkey);
}
/// <summary>
/// 临时使用数据库(单次有效)
Expand All @@ -100,7 +100,7 @@ public IFreeSql Use(TDBKey dbkey)
{
var oldkey = _dbkeyCurrent.Value;
if (_distributeTraceEnable && object.Equals(dbkey, oldkey) == false) _distributedTraceCall($"数据库使用[Use] {dbkey}");
return new FreeSqlCloundSnapshot<TDBKey>(this, dbkey, default);
return new FreeSqlCloundSnapshot<TDBKey>(this, dbkey, null);
}
internal IFreeSql GetBySnapshot(TDBKey dbkey)
{
Expand Down
8 changes: 4 additions & 4 deletions src/FreeSql.Cloud/FreeSqlCloundSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class FreeSqlCloundSnapshot<TDBKey> : IFreeSql
{
readonly FreeSqlCloud<TDBKey> _fsqlc;
readonly TDBKey _current;
readonly TDBKey _old;
readonly Action _dispose;

public FreeSqlCloundSnapshot(FreeSqlCloud<TDBKey> fsqlc, TDBKey current, TDBKey old)
public FreeSqlCloundSnapshot(FreeSqlCloud<TDBKey> fsqlc, TDBKey current, Action dispose)
{
_fsqlc = fsqlc;
_current = current;
_old = old;
_dispose = dispose;
}

public IAdo Ado => _fsqlc.GetBySnapshot(_current).Ado;
Expand All @@ -34,7 +34,7 @@ public void Dispose()
//{

//}
_fsqlc.Change(_old);
_dispose?.Invoke();
}

public void Transaction(Action handler) => _fsqlc.GetBySnapshot(_current).Transaction(handler);
Expand Down

0 comments on commit 3ef961a

Please sign in to comment.