public static int ExcuteWithTrans(string sql) { var sp = new SqlAndParam(); sp.Sql = sql; return(ExcuteWithTrans(sp)); }
public static int ExcuteWithTrans(SqlAndParam sp) { int rows = 0; using (var conn = GetDbConnection()) { conn.Open(); using (var tran = conn.BeginTransaction()) { try { rows = conn.Execute(sp.Sql, sp.Param, tran, null, null); tran.Commit(); } catch (Exception ex) { rows = 0; tran.Rollback(); throw ex; } } } return(rows); }
public static async Task <IEnumerable <T> > AsyncQuery <T>(SqlAndParam sp) { return(await AsyncQuery <T>(sp.Sql, sp.Param)); }