Beispiel #1
0
 /// <summary>
 /// Generates a value suitable to be concat in a SQL query with mysql concat function.
 /// Doesn't take into account the actual value, just the type.
 /// </summary>
 /// <returns></returns>
 internal string WrapSqlValue()
 {
     if (StoreType.IsString(Type) || StoreType.IsDateTime(Type))
     {
         return(string.Format(" if( {0} is null, 'NULL', concat( '''', {0}, '''' ))", Name));
     }
     else
     {
         return(string.Format(" if( {0} is null, 'NULL', {0} )", Name));
     }
 }
Beispiel #2
0
 public static string WrapValue(string Type, object Value)
 {
     if (Value == null || Value == DBNull.Value)
     {
         return("NULL");
     }
     else if (StoreType.IsString(Type) || StoreType.IsDateTime(Type))
     {
         return(string.Format("'{0}'", Value));
     }
     else if (Debugger.Cmp(Type, "bit") == 0)
     {
         return((Convert.ToInt32(Value) == 1) ? "1" : "0");
     }
     else
     {
         return(Value.ToString());
     }
 }