Ejemplo n.º 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();
         }
     }
 }
Ejemplo n.º 2
0
 /// <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();
         }
     }
 }
Ejemplo n.º 3
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();
                }
            }
        }
Ejemplo n.º 4
0
        /// <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();
                }
            }
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
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();
         }
     }
 }