public decimal GetDecimal(int i)
 {
     // Fix overflow problems when reading decimals
     return(OracleTypeHelper.FixDecimalPrecision(reader.GetOracleDecimal(i)));
 }
 public string GetString(int i)
 {
     // Fix empty string
     return(OracleTypeHelper.FixEmptyString(reader.GetString(i)));
 }
Пример #3
0
        public override object TransformDatabaseToRuntimeValue(object value)
        {
            if (value == null || value == DBNull.Value)
            {
                return(value);
            }

            var valueAsString = value as string;

            if (valueAsString != null)
            {
                // Fix empty string
                return(OracleTypeHelper.FixEmptyString(valueAsString));
            }

            var valueAsNullable = value as INullable;

            if (valueAsNullable != null && valueAsNullable.IsNull)
            {
                return(DBNull.Value);
            }

            var valueAsConvertible = value as IConvertible;

            if (valueAsConvertible != null)
            {
                return(valueAsConvertible);
            }

            // Common types

            var isString = value is OracleString;

            if (isString)
            {
                return(OracleTypeHelper.FixEmptyString(((OracleString)value).Value));
            }

            var isDecimal = value is OracleDecimal;

            if (isDecimal)
            {
                // Fix decimal precision
                try {
                    return(OracleTypeHelper.FixDecimalPrecision((OracleDecimal)value));
                } catch (Exception) { // In this case we are mapping the column to Text
                    return(value.ToString());
                }
            }

            var isTimestamp = value is OracleTimeStamp;

            if (isTimestamp)
            {
                return(((OracleTimeStamp)value).Value);
            }

            var clobValue = value as OracleClob;

            if (clobValue != null)
            {
                return(clobValue.Value);
            }

            var blobValue = value as OracleBlob;

            if (blobValue != null)
            {
                return(blobValue.Value);
            }

            // Other types

            var isDate = value is OracleDate;

            if (isDate)
            {
                return(((OracleDate)value).Value);
            }

            var isTimestampTZ = value is OracleTimeStampTZ;

            if (isTimestampTZ)
            {
                return(((OracleTimeStampTZ)value).Value);
            }

            var isTimestampLTZ = value is OracleTimeStampLTZ;

            if (isTimestampLTZ)
            {
                return(((OracleTimeStampLTZ)value).Value);
            }

            var isIntervalDS = value is OracleIntervalDS;

            if (isIntervalDS)
            {
                return(((OracleIntervalDS)value).Value);
            }

            var isIntervalYM = value is OracleIntervalYM;

            if (isIntervalYM)
            {
                return(((OracleIntervalYM)value).Value);
            }

            var isBinary = value is OracleBinary;

            if (isBinary)
            {
                return(((OracleBinary)value).Value);
            }

            var bFileValue = value as OracleBFile;

            if (bFileValue != null)
            {
                return(bFileValue.Value);
            }

            var xmlValue = value as OracleXmlType;

            if (xmlValue != null)
            {
                return(xmlValue.Value);
            }

            return(value);
        }