FirebirdDecFloatToTextResolver

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

This IResolver<object, string> implementation converts the value of a DECFLOAT(16) or DECFLOAT(34) column, as returned by the FirebirdSql.Data.FirebirdClient driver, into its text form. The driver returns an FbDecFloat, but a decimal or a string is accepted as well. It is used by the FirebirdDecFloatToStringPropertyHandler and, through the FirebirdDecFloatToDecimalResolver, by the decimal property handlers.

  • A null or DBNull value is resolved as null.
  • A string is returned as is.
  • A decimal is formatted with the invariant culture.
  • An FbDecFloat is formatted in its plain form (e.g. 123.45, and not the 12345E-2 scientific form the driver produces for a negative exponent). When the value has more than 28 digits, which is more than a decimal can hold, the scientific form is returned as is so that the precision is never altered.

An ArgumentException is thrown when the type of the value is not supported.

Usability

var resolver = new FirebirdDecFloatToTextResolver();
var text = resolver.Resolve(reader.GetValue(0)); // "123.45"