mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	- 修复 Ado.Net Crud 扩展方法事务的友好异常提示;
This commit is contained in:
		@@ -532,5 +532,14 @@
 | 
				
			|||||||
            <param name="that"></param>
 | 
					            <param name="that"></param>
 | 
				
			||||||
            <returns></returns>
 | 
					            <returns></returns>
 | 
				
			||||||
        </member>
 | 
					        </member>
 | 
				
			||||||
 | 
					        <member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
 | 
				
			||||||
 | 
					            <summary>
 | 
				
			||||||
 | 
					            批量注入 Repository,可以参考代码自行调整
 | 
				
			||||||
 | 
					            </summary>
 | 
				
			||||||
 | 
					            <param name="services"></param>
 | 
				
			||||||
 | 
					            <param name="globalDataFilter"></param>
 | 
				
			||||||
 | 
					            <param name="assemblies"></param>
 | 
				
			||||||
 | 
					            <returns></returns>
 | 
				
			||||||
 | 
					        </member>
 | 
				
			||||||
    </members>
 | 
					    </members>
 | 
				
			||||||
</doc>
 | 
					</doc>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,21 @@ namespace FreeSql.Tests.AdoNetExtensions.MySqlConnectionExtensions {
 | 
				
			|||||||
			Assert.Equal(1, affrows);
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void InsertOrUpdate()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								var affrows = 0;
 | 
				
			||||||
 | 
								using (var conn = new MySqlConnection(_connectString))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									var item = new TestConnectionExt { title = "testinsert" };
 | 
				
			||||||
 | 
									affrows = conn.Insert<TestConnectionExt>().AppendData(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
									item.title = "testinsertorupdate";
 | 
				
			||||||
 | 
									var affrows2 = conn.InsertOrUpdate<TestConnectionExt>().SetSource(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									conn.Close();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
		public void Update() {
 | 
							public void Update() {
 | 
				
			||||||
			var affrows = 0;
 | 
								var affrows = 0;
 | 
				
			||||||
			using (var conn = new MySqlConnection(_connectString)) {
 | 
								using (var conn = new MySqlConnection(_connectString)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,21 @@ namespace FreeSql.Tests.AdoNetExtensions.NpgsqlConnectionExtensions {
 | 
				
			|||||||
			Assert.Equal(1, affrows);
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void InsertOrUpdate()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								var affrows = 0;
 | 
				
			||||||
 | 
								using (var conn = new NpgsqlConnection(_connectString))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									var item = new TestConnectionExt { title = "testinsert" };
 | 
				
			||||||
 | 
									affrows = conn.Insert<TestConnectionExt>().AppendData(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
									item.title = "testinsertorupdate";
 | 
				
			||||||
 | 
									var affrows2 = conn.InsertOrUpdate<TestConnectionExt>().SetSource(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									conn.Close();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
		public void Update() {
 | 
							public void Update() {
 | 
				
			||||||
			var affrows = 0;
 | 
								var affrows = 0;
 | 
				
			||||||
			using (var conn = new NpgsqlConnection(_connectString)) {
 | 
								using (var conn = new NpgsqlConnection(_connectString)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,21 @@ namespace FreeSql.Tests.AdoNetExtensions.OracleConnectionExtensions {
 | 
				
			|||||||
			Assert.Equal(1, affrows);
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void InsertOrUpdate()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								var affrows = 0;
 | 
				
			||||||
 | 
								using (var conn = new OracleConnection(_connectString))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									var item = new TestConnectionExt { title = "testinsert" };
 | 
				
			||||||
 | 
									affrows = conn.Insert<TestConnectionExt>().AppendData(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
									item.title = "testinsertorupdate";
 | 
				
			||||||
 | 
									var affrows2 = conn.InsertOrUpdate<TestConnectionExt>().SetSource(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									conn.Close();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
		public void Update() {
 | 
							public void Update() {
 | 
				
			||||||
			var affrows = 0;
 | 
								var affrows = 0;
 | 
				
			||||||
			using (var conn = new OracleConnection(_connectString)) {
 | 
								using (var conn = new OracleConnection(_connectString)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,21 @@ namespace FreeSql.Tests.AdoNetExtensions.SQLiteConnectionExtensions {
 | 
				
			|||||||
			Assert.Equal(1, affrows);
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void InsertOrUpdate()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								var affrows = 0;
 | 
				
			||||||
 | 
								using (var conn = new SQLiteConnection(_connectString))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									var item = new TestConnectionExt { title = "testinsert" };
 | 
				
			||||||
 | 
									affrows = conn.Insert<TestConnectionExt>().AppendData(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
									item.title = "testinsertorupdate";
 | 
				
			||||||
 | 
									var affrows2 = conn.InsertOrUpdate<TestConnectionExt>().SetSource(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									conn.Close();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
		public void Update() {
 | 
							public void Update() {
 | 
				
			||||||
			var affrows = 0;
 | 
								var affrows = 0;
 | 
				
			||||||
			using (var conn = new SQLiteConnection(_connectString)) {
 | 
								using (var conn = new SQLiteConnection(_connectString)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,21 @@ namespace FreeSql.Tests.AdoNetExtensions.SqlConnectionExtensions {
 | 
				
			|||||||
			Assert.Equal(1, affrows);
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		[Fact]
 | 
							[Fact]
 | 
				
			||||||
 | 
							public void InsertOrUpdate()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								var affrows = 0;
 | 
				
			||||||
 | 
								using (var conn = new SqlConnection(_connectString))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									var item = new TestConnectionExt { title = "testinsert" };
 | 
				
			||||||
 | 
									affrows = conn.Insert<TestConnectionExt>().AppendData(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
									item.title = "testinsertorupdate";
 | 
				
			||||||
 | 
									var affrows2 = conn.InsertOrUpdate<TestConnectionExt>().SetSource(item).ExecuteAffrows();
 | 
				
			||||||
 | 
									conn.Close();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								Assert.Equal(1, affrows);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							[Fact]
 | 
				
			||||||
		public void Update() {
 | 
							public void Update() {
 | 
				
			||||||
			var affrows = 0;
 | 
								var affrows = 0;
 | 
				
			||||||
			using (var conn = new SqlConnection(_connectString)) {
 | 
								using (var conn = new SqlConnection(_connectString)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ namespace FreeSql
 | 
				
			|||||||
        static object _dicCurdLock = new object();
 | 
					        static object _dicCurdLock = new object();
 | 
				
			||||||
        static IFreeSql GetCrud(IDbConnection dbconn)
 | 
					        static IFreeSql GetCrud(IDbConnection dbconn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (dbconn == null) throw new ArgumentNullException($"{nameof(dbconn)} 不能为 null"); ;
 | 
					            if (dbconn == null) throw new ArgumentNullException($"{nameof(dbconn)} 不能为 null");
 | 
				
			||||||
            Type dbconType = dbconn.GetType();
 | 
					            Type dbconType = dbconn.GetType();
 | 
				
			||||||
            var connType = dbconType.UnderlyingSystemType;
 | 
					            var connType = dbconType.UnderlyingSystemType;
 | 
				
			||||||
            if (_dicCurd.TryGetValue(connType, out var fsql)) return fsql;
 | 
					            if (_dicCurd.TryGetValue(connType, out var fsql)) return fsql;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -202,9 +202,12 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (_transaction == null)
 | 
					                if (_transaction == null)
 | 
				
			||||||
                    this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					                {
 | 
				
			||||||
 | 
					                    var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                    if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (_transaction != null)
 | 
					                if (_transaction != null || _orm.Ado.MasterPool == null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _source = ss.Item1;
 | 
					                    _source = ss.Item1;
 | 
				
			||||||
                    _SplitSourceByIdentityValueIsNullFlag = 1;
 | 
					                    _SplitSourceByIdentityValueIsNullFlag = 1;
 | 
				
			||||||
@@ -305,9 +308,12 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (_transaction == null)
 | 
					                if (_transaction == null)
 | 
				
			||||||
                    this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					                {
 | 
				
			||||||
 | 
					                    var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                    if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (_transaction != null)
 | 
					                if (_transaction != null || _orm.Ado.MasterPool == null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _source = ss.Item1;
 | 
					                    _source = ss.Item1;
 | 
				
			||||||
                    _SplitSourceByIdentityValueIsNullFlag = 1;
 | 
					                    _SplitSourceByIdentityValueIsNullFlag = 1;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -219,7 +219,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrows", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrows", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -237,6 +240,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
					                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
@@ -294,7 +298,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteIdentity", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteIdentity", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -313,6 +320,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
					                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
@@ -371,7 +379,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteInserted", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteInserted", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -389,6 +400,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
					                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrowsAsync", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrowsAsync", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -51,6 +54,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
					                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
@@ -108,7 +112,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteIdentityAsync", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteIdentityAsync", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -127,6 +134,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
					                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
@@ -185,7 +193,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteInsertedAsync", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteInsertedAsync", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -203,6 +214,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
					                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,7 +158,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrows", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrows", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -176,6 +179,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
					                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
@@ -228,7 +232,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteUpdated", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteUpdated", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -246,6 +253,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
					                    using (var conn = _orm.Ado.MasterPool.Get())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrowsAsync", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteAffrowsAsync", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -47,6 +50,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
					                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
@@ -98,7 +102,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                return ret;
 | 
					                return ret;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_transaction == null)
 | 
					            if (_transaction == null)
 | 
				
			||||||
                this.WithTransaction(_orm.Ado.TransactionCurrentThread);
 | 
					            {
 | 
				
			||||||
 | 
					                var threadTransaction = _orm.Ado.TransactionCurrentThread;
 | 
				
			||||||
 | 
					                if (threadTransaction != null) this.WithTransaction(threadTransaction);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var before = new Aop.TraceBeforeEventArgs("SplitExecuteUpdatedAsync", null);
 | 
					            var before = new Aop.TraceBeforeEventArgs("SplitExecuteUpdatedAsync", null);
 | 
				
			||||||
            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
					            _orm.Aop.TraceBeforeHandler?.Invoke(this, before);
 | 
				
			||||||
@@ -116,6 +123,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (_orm.Ado.MasterPool == null) throw new Exception("Ado.MasterPool 值为 null,该操作无法自启用事务,请显式传递【事务对象】解决");
 | 
				
			||||||
                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
					                    using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        _transaction = conn.Value.BeginTransaction();
 | 
					                        _transaction = conn.Value.BeginTransaction();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user