示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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)));
        }
示例#4
0
        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));
        }
示例#5
0
 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);
 }
示例#6
0
        public virtual T GetParameterValue <T>(string name)
        {
            object value = owner.GetParameterValue(cmd, name);

            return(DbUtility.IsNullOrDBNull(value) ? default(T) : (T)value);
        }
示例#7
0
        public virtual T GetParameterValue <T>(int index)
        {
            object value = owner.GetParameterValue(cmd, index + 1);

            return(DbUtility.IsNullOrDBNull(value) ? default(T) : (T)value);
        }