コード例 #1
0
 /// <summary>
 /// 提交当前操作的结果
 /// </summary>
 public int Commit()
 {
     try
     {
         if (dbTransaction != null)
         {
             dbTransaction.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   = ExceptionMessage.GetSqlExceptionMessage(sqlEx.Number);
             throw DataAccessException.ThrowDataAccessException(sqlEx, msg);
         }
         throw;
     }
     finally
     {
         if (dbTransaction == null)
         {
             this.Close();
         }
     }
 }
コード例 #2
0
ファイル: MySqlDatabase.cs プロジェクト: Mouseww/JYT
 /// <summary>
 /// 提交当前操作的结果
 /// </summary>
 public int Commit()
 {
     try
     {
         int returnValue = dbcontext.SaveChanges();
         if (dbTransaction != null)
         {
             dbTransaction.Commit();
             this.Close();
         }
         return(returnValue);
     }
     catch (Exception ex)
     {
         LogFactory.GetLogger("Database").Error(ex);
         if (ex.InnerException != null && ex.InnerException.InnerException is SqlException)
         {
             SqlException sqlEx = ex.InnerException.InnerException as SqlException;
             string       msg   = ExceptionMessage.GetSqlExceptionMessage(sqlEx.Number);
             throw DataAccessException.ThrowDataAccessException(sqlEx, msg);
         }
         throw;
     }
     finally
     {
         if (dbTransaction == null)
         {
             this.Close();
         }
     }
 }
コード例 #3
0
ファイル: MySqlDatabase.cs プロジェクト: puxu1989/PXLib
        /// <summary>
        /// 提交当前操作的结果
        /// </summary>
        public int Commit()
        {
            int result;

            try
            {
                if (this.dbTransaction != null)
                {
                    this.dbTransaction.Commit();
                    this.Close();
                }
                result = 1;
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null && ex.InnerException.InnerException is SqlException)
                {
                    SqlException ex2 = ex.InnerException.InnerException as SqlException;
                    string       sqlExceptionMessage = ExceptionMessage.GetSqlExceptionMessage(ex2.Number);
                    throw DataAccessException.ThrowDataAccessException(ex2, sqlExceptionMessage);
                }
                throw;
            }
            finally
            {
                if (this.dbTransaction == null)
                {
                    this.Close();
                }
            }
            return(result);
        }
コード例 #4
0
        /// <summary>
        /// 提交当前操作的结果
        /// </summary>
        public int Commit()
        {
            try
            {
                if (_isusetran == true)
                {
                    Connection.Ado.CommitTran();
                    _isusetran = false;
                    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   = ExceptionMessage.GetSqlExceptionMessage(sqlEx.Number);
                    throw DataAccessException.ThrowDataAccessException(sqlEx, msg);
                }
                throw;
            }
            finally
            {
                if (_isusetran == false)
                {
                    this.Close();
                }
            }
        }
コード例 #5
0
 public int Commit()
 {
     try
     {
         var result = DbContext.SaveChanges();
         if (DbTransaction != null)
         {
             DbTransaction.Commit();
             Close();
         }
         return(result);
     }
     catch (Exception ex)
     {
         if (ex.InnerException != null && ex.InnerException.InnerException is SqlException)
         {
             var sqlEx = (SqlException)ex.InnerException.InnerException;
             var msg   = ExceptionMessage.GetSqlExceptionMessage(sqlEx.Number);
             throw DataAccessException.ThrowDataAccessException(sqlEx, msg);
         }
         throw;
     }
     finally
     {
         if (DbTransaction == null)
         {
             Close();
         }
     }
 }