Example #1
0
 /// <summary>
 /// SQL事物执行(增/改/删)相关操作
 /// </summary>
 /// <param name="transaction">SQL事物对象</param>
 /// <param name="dbHelper">数据库引擎</param>
 /// <param name="commandText">执行的SQL语句</param>
 /// <param name="commandParameters">携带的参数可以是Null</param>
 /// <returns></returns>
 public static DbTransResult ExecuteNonQuery(this DbTransaction transaction, DbHelper dbHelper, string commandText, params DbParameter[] commandParameters)
 {
     if (string.IsNullOrWhiteSpace(commandText))
     {
         throw new ArgumentException("执行SQL为空!", nameof(commandText));
     }
     return(transaction.ExecuteNonQuery(dbHelper, new SqlTextParameter(commandText, commandParameters)));
 }
Example #2
0
 public int MergePerson(DbTransaction transaction, PersonRowData oldPerson, Person newPerson)
 {
     return
         (transaction.ExecuteNonQuery(
              tables.Join(";\n\n\n", t => t.UpdateSql)
              + ";\n\n\nUPDATE Data.MasterDirectory SET StripeId = @oldStripeId WHERE Id = @newId AND StripeId IS NULL"
              + ";\n\n\nDELETE FROM Data.MasterDirectory WHERE Id = @oldId", new { oldId = oldPerson.Person.Id, newId = newPerson.Id, oldStripeId = oldPerson.StripeId }));
 }
Example #3
0
 ///<summary>Executes a SQL statement against a connection.</summary>
 ///<param name="transaction">The transaction to the database.  The connection is not closed.</param>
 ///<param name="sql">The SQL to execute.</param>
 ///<returns>The number of rows affected by the statement.</returns>
 public static int ExecuteNonQuery(this DbTransaction transaction, string sql)
 {
     return(transaction.ExecuteNonQuery <object>(sql, null));
 }
Example #4
0
 /// <summary>
 /// SQL事物执行(增/改/删)相关操作
 /// </summary>
 /// <param name="transaction">SQL事物对象</param>
 /// <param name="dbHelper">数据库引擎</param>
 /// <param name="commandText">执行的SQL语句</param>
 /// <param name="parameters">携带的参数可以是Null,虚构参数</param>
 /// <returns></returns>
 public static DbTransResult ExecuteNonQuery(this DbTransaction transaction, DbHelper dbHelper, string commandText, object parameters)
 {
     return(transaction.ExecuteNonQuery(dbHelper, commandText, dbHelper.SetParameters(parameters)));
 }
Example #5
0
 public int DeletePerson(DbTransaction transaction, Person person)
 {
     return(transaction.ExecuteNonQuery(tables.Join(";\n", t => t.DeleteSql) + ";\n\nDELETE FROM Data.MasterDirectory WHERE Id = @Id", new { person.Id }));
 }