事务嵌套的处理方案
using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.BusinessDbType, BaseSystemInfo.BusinessDbConnection)) { try { // 开启事务 IDbTransaction tran = dbHelper.BeginTransaction(); sqlBuilder = new SQLBuilder(dbHelper); sqlBuilder.BeginUpdate("CUSTOMER_GLOBAL"); SetCustomerGlobalObject(sqlBuilder, dr); sqlBuilder.SetWhere("ID", id); resultSQL = sqlBuilder.EndUpdate(); if (resultSQL == 0) { sqlBuilder = new SQLBuilder(dbHelper, false, true); sqlBuilder.BeginInsert("CUSTOMER_GLOBAL"); sqlBuilder.SetValue("ID", id); SetCustomerGlobalObject(sqlBuilder, dr); resultSQL = sqlBuilder.EndInsert(); isAdd = true; } // 其它批量处理的事务 tran.Connection IBatcherHelperService batcher = dbHelper.GetService<IBatcherHelperService>(); batcher.Insert(dataExtension,1000, tran.Connection); // 提交事务 dbHelper.CommitTransaction(); } catch (Exception ex) { // 回滚事务 dbHelper.RollbackTransaction(); } finally { }