From 3ef961a39a26360c87c0a2458ff5eb889c7e9cf6 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Fri, 10 Nov 2023 18:54:56 +0800 Subject: [PATCH] v1.6.8 --- README.md | 2 +- src/FreeSql.Cloud/FreeSql.Cloud.csproj | 2 +- src/FreeSql.Cloud/FreeSqlCloud.cs | 4 ++-- src/FreeSql.Cloud/FreeSqlCloundSnapshot.cs | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e19be14..2c446cb 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ fsql.Use(DbEnum.db2).Select(); using (fsql.Change(DbEnum.db2)) { //todo.. } -//FreeSql.Cloud v1.6.7 一个范围内切换,之后再切换回去 +//FreeSql.Cloud v1.6.8 一个范围内切换,之后再切换回去 ``` 自动定向数据库配置: diff --git a/src/FreeSql.Cloud/FreeSql.Cloud.csproj b/src/FreeSql.Cloud/FreeSql.Cloud.csproj index 90db61b..9f43ea6 100644 --- a/src/FreeSql.Cloud/FreeSql.Cloud.csproj +++ b/src/FreeSql.Cloud/FreeSql.Cloud.csproj @@ -2,7 +2,7 @@ netstandard20;net40 - 1.6.7 + 1.6.8 true FreeSql;ncc;YeXiangQin 提供跨数据库访问,分布式事务TCC、SAGA解决方案,支持 .NET Core 2.1+, .NET Framework 4.0+. diff --git a/src/FreeSql.Cloud/FreeSqlCloud.cs b/src/FreeSql.Cloud/FreeSqlCloud.cs index f06e701..1a35365 100644 --- a/src/FreeSql.Cloud/FreeSqlCloud.cs +++ b/src/FreeSql.Cloud/FreeSqlCloud.cs @@ -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(this, dbkey, oldkey); + return new FreeSqlCloundSnapshot(this, dbkey, () => _dbkeyCurrent.Value = oldkey); } /// /// 临时使用数据库(单次有效) @@ -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(this, dbkey, default); + return new FreeSqlCloundSnapshot(this, dbkey, null); } internal IFreeSql GetBySnapshot(TDBKey dbkey) { diff --git a/src/FreeSql.Cloud/FreeSqlCloundSnapshot.cs b/src/FreeSql.Cloud/FreeSqlCloundSnapshot.cs index 603637a..abae65e 100644 --- a/src/FreeSql.Cloud/FreeSqlCloundSnapshot.cs +++ b/src/FreeSql.Cloud/FreeSqlCloundSnapshot.cs @@ -13,13 +13,13 @@ class FreeSqlCloundSnapshot : IFreeSql { readonly FreeSqlCloud _fsqlc; readonly TDBKey _current; - readonly TDBKey _old; + readonly Action _dispose; - public FreeSqlCloundSnapshot(FreeSqlCloud fsqlc, TDBKey current, TDBKey old) + public FreeSqlCloundSnapshot(FreeSqlCloud fsqlc, TDBKey current, Action dispose) { _fsqlc = fsqlc; _current = current; - _old = old; + _dispose = dispose; } public IAdo Ado => _fsqlc.GetBySnapshot(_current).Ado; @@ -34,7 +34,7 @@ public void Dispose() //{ //} - _fsqlc.Change(_old); + _dispose?.Invoke(); } public void Transaction(Action handler) => _fsqlc.GetBySnapshot(_current).Transaction(handler);