public IDataReader InstanceExecuteReader(string sql, Map map) { Logger.Info("InstanceExecuteReader " + sql); Logger.Debug(map.ToShortJson()); if (this.Connection == null) return null; string modifiedSql = sql; CommandType ct = CommandType.Text; string[] paramNames = this.PrepareParameters(ref modifiedSql, ref ct); IDataParameter[] parms = this.FillParameters(paramNames, map); if (this.Transaction == null) return DbHelper.ExecuteReader(this.Connection, ct, modifiedSql, parms); else return DbHelper.ExecuteReader(this.Transaction, ct, modifiedSql, parms); }
public static IDataReader ExecuteReaderQs(string type, string query, Map map) { Logger.Info(String.Format("ExecuteReaderQs({0}, {1})", type, query)); Logger.Debug(map.ToShortJson()); SfCommand cmd; ServerFacade sf = ServerFacade.Current; if (sf.Connection == null) return null; if (!sf.GetFromQueryStore(type, query, out cmd)) return null; IDataParameter[] parms = sf.FillParameters(cmd.GetParams(0), map); if (sf.Transaction == null) return DbHelper.ExecuteReader(sf.Connection, cmd.GetCommandType(0), cmd.GetText(0), parms); else return DbHelper.ExecuteReader(sf.Transaction, cmd.GetCommandType(0), cmd.GetText(0), parms); }
public int InstanceExecuteNonQuery(string sql, Map map) { Logger.Info("InstanceExecuteNonQuery " + sql); Logger.Debug(map.ToShortJson()); ServerFacade sf = this; if (sf.Connection == null) return 0; int ret = -1; foreach (string singleSql in sql.Split(';')) { string modifiedSql = singleSql; CommandType ct = CommandType.Text; string[] paramNames = sf.PrepareParameters(ref modifiedSql, ref ct); IDataParameter[] parms = sf.FillParameters(paramNames, map); if (sf.Transaction == null) ret = DbHelper.ExecuteNonQuery(sf.Connection, ct, modifiedSql, parms); else ret = DbHelper.ExecuteNonQuery(sf.Transaction, ct, modifiedSql, parms); foreach (IDataParameter p in parms) if (p.Direction == ParameterDirection.ReturnValue) ret = Convert.ToInt32(p.Value); } return ret; }
public static int ExecuteNonQueryQs(string type, string query, Map map) { Logger.Info(String.Format("ExecuteNonQueryQs({0}, {1})", type, query)); Logger.Debug(map.ToShortJson()); SfCommand cmd; ServerFacade sf = ServerFacade.Current; if (sf.Connection == null) return 0; if (!sf.GetFromQueryStore(type, query, out cmd)) return 0; int ret = 0; for (int i = 0; i < cmd.GetCommandCount(); i++) { IDataParameter[] parms = sf.FillParameters(cmd.GetParams(i), map); if (sf.Transaction == null) ret = DbHelper.ExecuteNonQuery(sf.Connection, cmd.GetCommandType(i), cmd.GetText(i), parms); else ret = DbHelper.ExecuteNonQuery(sf.Transaction, cmd.GetCommandType(i), cmd.GetText(i), parms); } return ret; }