public List <T> ExecuteProcedure <T>(string proName, BFParameters parms) { string proc = proName; var ps = parms.GetDbParameters(ref proc); return(Database.SqlQuery <T>(proc, ps).ToList()); }
/// <summary> /// /// </summary> /// <param name="proName"></param> /// <param name="parms"></param> /// <returns></returns> public int ExecuteProcedure(string proName, BFParameters parms) { string proc = proName; var ps = parms.GetDbParameters(ref proc); var res = Database.SqlQuery <int>(proc, ps); return(res.FirstOrDefault()); }
public int MysqlExecuteProcedure(string proName, BFParameters parms) { string proc = ""; var ps = parms.GetDbParameters(ref proc); using (DbConnection conn = Database.Connection) { if (conn.State != ConnectionState.Open) { conn.Open(); } DbCommand cmd = Database.Connection.CreateCommand(); cmd.CommandText = proName; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddRange(ps); return(cmd.ExecuteNonQuery()); } }
public int MysqlExecuteProcedure(string proName, BFParameters parms) { string proc = ""; var ps = parms.GetDbParameters(ref proc); using (DbConnection conn = Database.Connection) { try { if (conn.State != ConnectionState.Open) { conn.Open(); } // var t= conn.BeginTransaction(); try { DbCommand cmd = Database.Connection.CreateCommand(); cmd.CommandText = proName; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddRange(ps); cmd.ExecuteNonQuery(); // t.Commit(); } catch (Exception) { // t.Rollback(); } return(0); } catch (Exception) { return(-1); } } }
/// <summary> /// /// </summary> /// <param name="proName"></param> /// <param name="parms"></param> /// <returns></returns> public int ExecuteProcedure(string proName, BFParameters parms) { string proc = proName; var ps = parms.GetDbParameters(ref proc); //return Database.ExecuteSqlCommand(proc, ps); // var res = Database.SqlQuery<int>(proc, ps); //return res.FirstOrDefault(); DbConnection conn = Database.Connection; if (conn.State != ConnectionState.Open) { conn.Open(); } DbCommand cmd = Database.Connection.CreateCommand(); cmd.CommandText = "sp_paycheck"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddRange(ps); return(cmd.ExecuteNonQuery()); }