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

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

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