/// <summary> /// 提交当前操作的结果 /// </summary> public int Commit() { try { if (SqlTransaction != null) { SqlTransaction.Commit(); this.Close(); } return(1); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException is SqlException) { SqlException sqlEx = ex.InnerException.InnerException as SqlException; string msg = ExceptionMessageHelper.GetSqlExceptionMessage(sqlEx.Number); throw DataAccessException.ThrowDataAccessException(sqlEx, msg); } return(0); } finally { if (SqlTransaction == null) { this.Close(); } } }
/// <summary> /// 提交当前操作的结果 /// </summary> public int Commit() { try { int returnValue = Dbcontext.SaveChanges(); if (DbTransaction != null) { DbTransaction.Commit(); this.Close(); } return(returnValue); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException is SqlException) { SqlException sqlEx = ex.InnerException.InnerException as SqlException; string msg = ExceptionMessageHelper.GetSqlExceptionMessage(sqlEx.Number); throw DataAccessException.ThrowDataAccessException(sqlEx, msg); } throw; } finally { if (DbTransaction == null) { this.Close(); } } }