public DataTable ExecuteDataTable(int startRecord, int maxRecords, string formatSql, params object[] paramValues) { string text = DbUtility.GetFormat(formatSql, paramValues); var cmd = this.PrepareCommand(text, CommandType.Text); return(this.ExecuteDataTable(cmd, startRecord, maxRecords)); }
public DbDataReader ExecuteReader(string formatSql, params object[] paramValues) { string text = DbUtility.GetFormat(formatSql, paramValues); var cmd = this.PrepareCommand(text, CommandType.Text); return(this.ExecuteReader(cmd)); }
public T ExecuteScalar <T>(string formatSql, params object[] paramValues) { string text = DbUtility.GetFormat(formatSql, paramValues); var cmd = this.PrepareCommand(text, CommandType.Text); return((T)Convert.ChangeType(this.ExecuteScalar(cmd), typeof(T))); }
public int ExecuteNonQuery(string formatSql, params object[] paramValues) { string text = DbUtility.GetFormat(formatSql, paramValues); var cmd = this.PrepareCommand(text, CommandType.Text); return(this.ExecuteNonQuery(cmd)); }
internal static StringBuilder AppendValue(this StringBuilder buffer, object value) { if (DbUtility.IsNullOrDBNull(value)) { buffer.Append("NULL"); } else { Type type = value.GetType(); type = Nullable.GetUnderlyingType(type) ?? type; string sValue = value.ToString(); if (type.IsPrimitive) { if (type == typeof(bool)) { buffer.Append(sValue == bool.FalseString ? "0" : "1"); } else { buffer.Append(sValue); } } else { if (type == typeof(DateTime) || type == typeof(Guid)) { buffer.Append(DbUtility.Special).Append(sValue).Append(DbUtility.Special); } else { buffer.Append(DbUtility.Special).Append(sValue.Replace(DbUtility.Special, string.Empty)).Append(DbUtility.Special); } } } return(buffer); }
public virtual T GetParameterValue <T>(string name) { object value = owner.GetParameterValue(cmd, name); return(DbUtility.IsNullOrDBNull(value) ? default(T) : (T)value); }
public virtual T GetParameterValue <T>(int index) { object value = owner.GetParameterValue(cmd, index + 1); return(DbUtility.IsNullOrDBNull(value) ? default(T) : (T)value); }