public int Update(string sql, Dictionary <string, object> parms) { PrintSql(sql); OracleConnection conn = null; try { conn = OracleConnectionFactory.OpenConn(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.CommandType = CommandType.Text; ParameterHandler.SetParameters(cmd, parms); return(cmd.ExecuteNonQuery()); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { OracleConnectionFactory.CloseConn(conn); } return(-1); }
public List <Dictionary <string, object> > QueryMapList(string sql, Dictionary <string, object> parms) { PrintSql(sql); OracleConnection conn = null; var result = new List <Dictionary <string, object> >(); try { conn = OracleConnectionFactory.OpenConn(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.CommandType = CommandType.Text; ParameterHandler.SetParameters(cmd, parms); var reader = cmd.ExecuteReader(); result = ResultHandler.GenerateResultMapFromTable(reader); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { OracleConnectionFactory.CloseConn(conn); } return(result); }
public long QueryCount(string sql, Dictionary <string, object> parms) { PrintSql(sql); OracleConnection conn = null; long result = 0; try { conn = OracleConnectionFactory.OpenConn(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.CommandType = CommandType.Text; ParameterHandler.SetParameters(cmd, parms); var count = cmd.ExecuteScalar(); result = Convert.ToInt64(count); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { OracleConnectionFactory.CloseConn(conn); } return(result); }