public override object ConvertDbValue(object value, Type expectedType) { if (value == null || value == DBNull.Value) { return(null); } if (expectedType.IsGenericType && expectedType.GetGenericTypeDefinition() == typeof(Nullable <>)) { Type innerType = Nullable.GetUnderlyingType(expectedType); return(ConvertDbValue(value, innerType)); } if (expectedType.IsEnum) { Type innerType = Enum.GetUnderlyingType(expectedType); return(Enum.ToObject(expectedType, ConvertDbValue(value, innerType))); } if (value is OracleDecimal) { OracleDecimal newValue = (OracleDecimal)value; if (expectedType == typeof(byte)) { return(newValue.ToByte()); } if (expectedType == typeof(Int16)) { return(newValue.ToInt16()); } if (expectedType == typeof(Int32)) { return(newValue.ToInt32()); } if (expectedType == typeof(Int64)) { return(newValue.ToInt64()); } if (expectedType == typeof(Single)) { return(newValue.ToSingle()); } if (expectedType == typeof(Double)) { return(newValue.ToDouble()); } if (expectedType == typeof(bool)) { return(Convert.ToBoolean(newValue.ToInt32())); } throw new Exception("未实现Oracle.ManagedDataAccess.Types.OracleDecimal转化" + expectedType); } return(Convert.ChangeType(value, expectedType)); }