I have a POCO that maps to a table in Oracle. The column SOU_SEQ
is of type NUMBER(10,0)
and the POCO that represents this column as a long
.
The problem is when I try to run a query against that table with Dapper and I get the following error:
System.Data.DataException: Error parsing column 8 (SOU_SEQ=09/07/2009 00:00:00 - DateTime) ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Devart.Data.Oracle.ad.d(Byte[] A_0, Int32 A_1, Int32 A_2) at Devart.Data.Oracle.OracleDataReader.b(Int32 A_0) at Devart.Data.Oracle.OracleDataReader.GetValue(Int32 i) at Devart.Common.DbDataReaderBase.get_Item(Int32 ordinal) at Deserialize3c89d5be-c520-433f-a74f-f2e0bad095da(IDataReader )
--- End of inner exception stack trace --- at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value) in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 4153 at Deserialize3c89d5be-c520-433f-a74f-f2e0bad095da(IDataReader ) at Dapper.SqlMapper.d__147`1.MoveNext() in D:\Dev\dapper-dot-net\Dapper NET45\SqlMapperAsync.cs:line 112
It appears that Dapper is trying to parse this column wrongly as a DateTime.
The code that I am using to query the database is as follows:
await connnection.QueryAsync<T>(@sql, token).ConfigureAwait(false);
The definition of T
would fill up several screens. However, the property SOU_SEQ
is implemented like this:
public class MappingClass
{
[System.ComponentModel.DataAnnotations.Key]
[System.ComponentModel.DataAnnotations.Required()]
[System.ComponentModel.DataAnnotations.Schema.Column(Order = 8)]
[System.ComponentModel.DataAnnotations.Schema.DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None)]
public virtual long SOU_SEQ
{
get;
set;
}
}
And the SQL that is used is SELECT * FROM SCHEMA.TABLE
*.
Is there any workaround for this issue?
*The reason for using *
is that we really do want all columns since this is part of an application that replicates between an Oracle and a SQL Server database (there are no primary keys in the 3rd party database we need to replicate).
It looks like, rather than being an issue with Dapper, it is due to a OutOfMemoryException
that most likely occurred while parsing the column in question. The table in question is the biggest we have to deal with and the logs show that the query was running for a considerable period of time before the exception occurred.
So, I'm going to add as a tentative answer that the message about a parsing error is not the problem but, rather, there was a memory issue during parsing that is unrelated to Dapper.