/// <summary> /// .NET Decimal has a max precision of 28, so we need to set it here to prevent overflow errors (#708477) /// </summary> internal static decimal FixDecimalPrecision(OracleDecimal value) { int nrDigitsIntegerPart = OracleDecimal.Floor(value).ToString().Length; try { // Try to convert to a decimal with 29 digits return(OracleDecimal.ConvertToPrecScale(value, 29, 29 - nrDigitsIntegerPart).Value); } catch (OverflowException) { // Value didn't fit a decimal with 29 digits, try with 28 digits return(OracleDecimal.ConvertToPrecScale(value, 28, 28 - nrDigitsIntegerPart).Value); } }