FirebirdDecFloatToDecimalResolver

A class used to resolve the value of a Firebird DECFLOAT column, as returned by the driver, into a decimal.

This IResolver<object, decimal?> implementation converts the value of a DECFLOAT(16) or DECFLOAT(34) column, as returned by the FirebirdSql.Data.FirebirdClient driver (an FbDecFloat, a decimal or a string), into a decimal. It is used by the FirebirdDecFloatToDecimalPropertyHandler and the FirebirdDecFloatToNullableDecimalPropertyHandler.

A null or DBNull value is resolved as null. The value is first converted into text by the FirebirdDecFloatToTextResolver, and then parsed with the invariant culture.

A DECFLOAT(34) can hold up to 34 digits, while a decimal holds up to 28-29. An OverflowException is thrown when the value is outside of the range of a decimal, and a FormatException when it is not a finite number (NaN or infinity). Use the FirebirdDecFloatToStringPropertyHandler if such values must be supported.

The counterpart of this class is the DecimalToFirebirdDecFloatResolver, which converts a decimal into the value written into the column.

Usability

var resolver = new FirebirdDecFloatToDecimalResolver();
var number = resolver.Resolve(reader.GetValue(0)); // 123.45m

Constructors

Constructor Description
FirebirdDecFloatToDecimalResolver() Creates a new instance using the FirebirdDecFloatToTextResolver.
FirebirdDecFloatToDecimalResolver(IResolver<object, string> textResolver) Creates a new instance using the custom resolver that converts the value returned by the driver into text.