/// <summary> /// 获取数据库事务访问对象 /// </summary> public IDbTranAccess BeginTran() { var _dbTran = DbFactory.BeginTransaction(DatabaseType, ConnectionString); _dbTran.ConnectionTimeout = this.ConnectionTimeout; _dbTran.CommandTimeout = this.CommandTimeout; return(_dbTran); }
public void BeginTransaction() { if (this.ActiveNumber == 0 && EnableUnitOfWork) { DbFactory.BeginTransaction(); Logger.LogDebug("开启事务"); } this.ActiveNumber++; }
/// <summary> /// 儲存所有變更儲存到基礎資料庫。(跨 Repository,並使用資料庫交易) /// </summary> public void SaveChanges() { try { DbFactory.BeginTransaction(); DbFactory.Get().SaveChanges(); DbFactory.Commit(); } catch { DbFactory.Rollback(); ObjectContext.Connection.Close(); Dispose(); throw; } }