Example #1
0
 public override int ExecuteSQLWithTransNonResult(DatabaseTransactionDelegate method,
                                                  IsolationLevel level = (IsolationLevel)4096)
 {
     using (SqlConnection conn = new SqlConnection(this.ConnectionString)) {
         try {
             conn.Open();
             using (SqlTransaction trans = conn.BeginTransaction(level)) {
                 using (SqlCommand cmd = conn.CreateCommand()) {
                     try {
                         cmd.Transaction = trans;
                         int count = method(cmd);
                         trans.Commit();
                         return(count);
                     } catch (Exception) {
                         trans.Rollback();
                         return(0);
                     }
                 }
             }
         } catch (SqlException) {
             return(0);
         } finally {
             if (conn.State == ConnectionState.Open)
             {
                 conn.Close();
             }
         }
     }
 }
Example #2
0
        public override int ExecuteSQLWithTransNonResult(DatabaseTransactionDelegate method, 
		                                                  IsolationLevel level = (IsolationLevel)4096)
        {
            using (MySqlConnection conn = new MySqlConnection(this.ConnectionString)) {
                try {
                    conn.Open ();
                    using (MySqlTransaction tran = conn.BeginTransaction(level)) {
                        using (MySqlCommand cmd = conn.CreateCommand()) {
                            try {
                                cmd.Transaction = tran;
                                int count = method (cmd);
                                tran.Commit ();
                                return count;
                            } catch (Exception) {
                                tran.Rollback ();
                                return 0;
                            }
                        }
                    }
                } catch (MySqlException) {
                    return 0;
                } finally {
                    if (conn.State == ConnectionState.Open) {
                        conn.Close ();
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// Executes the SQL with transaction non result.
 /// if you transaction is throw an exception
 /// please do not catch it
 /// we will rollback the data
 /// </summary>
 /// <returns>count of used rows</returns>
 /// <param name="method">Method.</param>
 /// <param name="level">Level.</param>
 public abstract int ExecuteSQLWithTransNonResult(DatabaseTransactionDelegate method,
                                                  IsolationLevel level = IsolationLevel.ReadCommitted);
Example #4
0
        /// <summary>
        /// Executes the SQL with transaction non result.
        /// if you transaction is throw an exception
        /// please do not catch it
        /// we will rollback the data
        /// </summary>
        /// <returns>count of used rows</returns>
        /// <param name="method">Method.</param>
        /// <param name="level">Level.</param>
        public abstract int ExecuteSQLWithTransNonResult(DatabaseTransactionDelegate method, 
		                                                  IsolationLevel level = IsolationLevel.ReadCommitted);