SuppressGetDecimalInvalidCastException
This property specifies whether to suppress the InvalidCastException
and return a rounded-off 28 or 29 precision Oracle NUMBER
value that can be represented as a .NET Decimal.
Declaration
// C# public bool SuppressGetDecimalInvalidCastException { get; set;}
Property Type
Sysyem.Boolean
Remarks
Oracle NUMBER
has a maximum of 38 precision. .NET Decimal has a maximum of 28 or 29 precision. When the OracleDataReader
GetDecimal()
, GetValue()
, or OracleDataAdapter
Fill()
method is called for an Oracle NUMBER
value that cannot be represented as a .NET Decimal, then ODP.NET throws an InvalidCastException
because not all the precision can be preserved when converting the number to a .NET Decimal.
This behavior occurs when SuppressGetDecimalInvalidCastException
is set to false
, which is the default value.
When SuppressGetDecimalInvalidCastException
is set to true
, the resulting .NET Decimal is rounded off to 28 or 29 precision, allowing as much of the value to be represented without throwing an exception. If the resulting rounded number is larger than can be stored in a .NET Decimal, an exception will be thrown, such as the number 1 x 10^32.
The SuppressGetDecimalInvalidCastException
property can also be configured on OracleConfiguration
, OracleDataReader
, and OracleDataAdapter
objects. The OracleConnection
SuppressGetDecimalInvalidCastException
property value inherits OracleConfiguration
SuppressGetDecimalInvalidCastException
property value at construction time.
By using OracleConnection.SuppressGetDecimalInvalidCastException
, this ODP.NET setting becomes enabled for all the connection's command executions. It can be overridden at the OracleDataReader
or OracleDataAdapter
level, which each has its own SuppressGetDecimalInvalidCastException
property.
See Also:
-
OracleConfiguration SuppressGetDecimalInvalidCastException
-
OracleDataReader SuppressGetDecimalInvalidCastException
-
OracleDataAdapter SuppressGetDecimalInvalidCastException
-
"Oracle.DataAccess.Client and Oracle.ManagedDataAccess.Client Namespaces"