AdoNetCore.AseClient
AdoNetCore.AseClient copied to clipboard
Sybase float column read as double by AseDataReader
I have a SyBase DB table with field of type "float", so I have declared a C# backend field of type "float" also.
When I execute ExecuteReader(sqlQuery), in the retourned AseDataReader class, the column type of field is "double". When converting this double value to backend "float" field I have precission loss.
How can I force AseDataReader to map column to "float" type as defined in DB ??
Environment
- .NET Core version 3.1
AdoNetCore.AseClient: 0.19.2
Please check on this issue and let me know if we are in correct path: https://github.com/linq2db/linq2db/issues/3183
Hello, I might be missing some informations but from what I can understand you're trying to use the GetFloat method of the AseDataReader class ?
if yes then you have 2 cases:
- the column you're dealing with is a float with a default precision strictly below 16: the your float is actually stored as a real (see https://infocenter-archive.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/blocks.pdf page 17, "Range, precision and storage size")
- the column you're dealing with is a float with a default precision greater or equal to 16 then your float is actually stored as a double
Now from my understanding of this driver implementation if you are in the first case then it will consider the value as TDS_FLT4 leading to being represented as a float while in the second case the value will be considered as TDS_FLT8 and will be represented as a double. Then if you call the GetFloat method on the second case you'll get a double that is then converted to a float.