When a database column contains number like 0.11212121212121356500008888888888874343468766
, it can't be fit to DataRow's generated Decimal-type column. This same applies to DataReader. With DataReader I have solved this with wrapper:
public class OracleDataReaderWrapper : DbDataReader
{
DbDataReader _realReader;
public OracleDataReaderWrapper(DbDataReader realReader)
{
_realReader = realReader;
}
//... all other methods
public override object GetValue(int ordinal)
{
if (_realReader is System.Data.OracleClient.OracleDataReader)
{
Type fieldType = _realReader.GetFieldType(ordinal);
if (fieldType == typeof(Decimal))
{
return (decimal)((double)((System.Data.OracleClient.OracleNumber)_realReader.GetProviderSpecificValue(ordinal)));
}
//...
But how can I do something with DataSet, DbDataAdapter? Rewriting all datadapter-Select commands with ROUND or TRUNC is not only wrong, it's out of question because there's already hundreds of places to change it.
NOTE this applies also to ODP.NET. There the type is OracleDecimal instead of OracleNumber. My wrapper is used for both clients.