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).
T,@sqland the relevant SQL DDL to your question? - Colin YoungSELECT SOU_SEQ FROM ... WHERE ...and see if you still experience the problem? ODP.Net might be the answer. - Colin Young