优化 IFreeSql.Transaction 可嵌套连续使用,之前会死锁

This commit is contained in:
28810 2019-04-01 16:15:59 +08:00
parent da1c6cd4f0
commit 1132a094ae
3 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Version>0.4.1</Version> <Version>0.4.1.2</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description> <Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>

View File

@ -48,6 +48,8 @@ namespace FreeSql.Internal.CommonProvider {
public void TransactionPreRemoveCache(params string[] key) => PreRemove(key); public void TransactionPreRemoveCache(params string[] key) => PreRemove(key);
public void BeginTransaction(TimeSpan timeout) { public void BeginTransaction(TimeSpan timeout) {
if (TransactionCurrentThread != null) return;
int tid = Thread.CurrentThread.ManagedThreadId; int tid = Thread.CurrentThread.ManagedThreadId;
Transaction2 tran = null; Transaction2 tran = null;
Object<DbConnection> conn = null; Object<DbConnection> conn = null;

View File

@ -388,7 +388,7 @@ namespace FreeSql.Internal.CommonProvider {
_paramsSource.Clear(); _paramsSource.Clear();
var colidx = 0; var colidx = 0;
foreach (var col in _table.Columns.Values) { foreach (var col in _table.Columns.Values) {
if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.CsName) == false) { if (col.Attribute.IsIdentity == false && col.Attribute.IsVersion == false && _ignore.ContainsKey(col.CsName) == false) {
if (colidx > 0) sb.Append(", "); if (colidx > 0) sb.Append(", ");
sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = "); sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = ");
var value = _table.Properties.TryGetValue(col.CsName, out var tryp) ? tryp.GetValue(_source.First()) : null; var value = _table.Properties.TryGetValue(col.CsName, out var tryp) ? tryp.GetValue(_source.First()) : null;
@ -414,7 +414,7 @@ namespace FreeSql.Internal.CommonProvider {
_paramsSource.Clear(); _paramsSource.Clear();
var colidx = 0; var colidx = 0;
foreach (var col in _table.Columns.Values) { foreach (var col in _table.Columns.Values) {
if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.CsName) == false) { if (col.Attribute.IsIdentity == false && col.Attribute.IsVersion == false && _ignore.ContainsKey(col.CsName) == false) {
if (colidx > 0) sb.Append(", "); if (colidx > 0) sb.Append(", ");
sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = "); sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = ");