Exemplo n.º 1
0
        protected string GetQuotedValue(object?val)
        {
            if (val == null)
            {
                return("NULL");
            }

            var type = val.GetType();

            switch (Type.GetTypeCode(type))
            {
            case TypeCode.Boolean:
                return(((bool)val) ? "1" : "0");

            case TypeCode.Single:
            case TypeCode.Double:
            case TypeCode.Decimal:
            case TypeCode.SByte:
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.Byte:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64:
                return(val.ToString() !);

            case TypeCode.DateTime:
                return(SqlSyntax.GetQuotedValue(SqlSyntax.FormatDateTime((DateTime)val)));

            default:
                return(SqlSyntax.GetQuotedValue(val.ToString() !));
            }
        }