/// <summary> /// Returns the string representation of the object. /// </summary> /// <param name="obj"></param> /// <param name="type"></param> /// <returns></returns> internal static string CreateString(object obj, ColumnType type) { if (obj == null) { return("NULL"); } switch (type) { case ColumnType.Null: return("NULL"); case ColumnType.Date: case ColumnType.Time: case ColumnType.Timestamp: return("'" + ((DateTime)obj).ToString("yyyy.MM.dd HH:mm:ss.fffffff") + "'"); case ColumnType.Other: return("'" + ByteArray.SerializeTostring(obj) + "'"); case ColumnType.Binary: case ColumnType.VarBinary: case ColumnType.LongVarBinary: { // we suppose that obj is ByteArray, which have ToString method // but defacto 'obj' is "System.Byte[]" if (obj is ByteArray) { return("'" + obj.ToString() + "'"); } else { return("'" + (new ByteArray((byte[])obj)).ToString() + "'"); } } case ColumnType.Real: case ColumnType.DbDouble: case ColumnType.DbDecimal: case ColumnType.Float: case ColumnType.Numeric: return(string.Format(CultureInfo.InvariantCulture.NumberFormat, "{0}", obj)); case ColumnType.VarCharIgnoreCase: case ColumnType.VarChar: case ColumnType.Char: case ColumnType.LongVarChar: return(CreateString((string)obj)); case ColumnType.UniqueIdentifier: return(CreateString(((Guid)obj).ToString())); default: return(obj.ToString()); } }
/// <summary> /// Returns the string representation of the object. /// </summary> /// <param name="obj"></param> /// <param name="type"></param> /// <returns></returns> internal static string CreateString(object obj, ColumnType type) { if (obj == null) { return("NULL"); } switch (type) { case ColumnType.Null: return("NULL"); case ColumnType.Date: case ColumnType.Time: case ColumnType.Timestamp: return("'" + ((DateTime)obj).ToString("yyyy.MM.dd HH:mm:ss.fffffff") + "'"); case ColumnType.Other: return("'" + ByteArray.SerializeTostring(obj) + "'"); case ColumnType.Binary: case ColumnType.VarBinary: case ColumnType.LongVarBinary: return("'" + obj.ToString() + "'"); case ColumnType.Real: case ColumnType.DbDouble: case ColumnType.DbDecimal: case ColumnType.Float: case ColumnType.Numeric: return("'" + Convert.ToString(obj, CultureInfo.InvariantCulture) + "'"); case ColumnType.VarCharIgnoreCase: case ColumnType.VarChar: case ColumnType.Char: case ColumnType.LongVarChar: return(CreateString((string)obj)); case ColumnType.UniqueIdentifier: return(CreateString(((Guid)obj).ToString())); default: return(obj.ToString()); } }