Page 1 of 1

OracleException when using custom valueconverter

Posted: Thu 11 Oct 2018 07:36
by domrin
Hi,

We're having an issue when using the entity framework core value converter (https://docs.microsoft.com/en-us/ef/cor ... onversions) in order to convert a column in an Oracle database that is stored as an int and representated by unix epoch time.

Here is what we use in our dbcontext to set up the column. Note that this does work with other entity framework providers as well as a couple of open source Oracle Entity Framework providers.

Code: Select all

var intDateConverter = new ValueConverter<DateTime, int>(
               v => v.ToEpochTime(),
               v => v.ToDateTimeFromEpoch()
           );

entity.Property(p => p.CreateDate).HasColumnName("CREATE_DATE").HasConversion(intDateConverter);
In the case above, p.CreateDate is a DateTime and the Column "CREATE_DATE" is stored as an INT in the oracle db.

This seems to function OK when doing basic SELECTs and the model seems to convert ok but when doing anything that requires a filter such as

Code: Select all

model.Where(m => m.CreateDate > someDateTime);
Then this is what is generated:

Code: Select all

SELECT CREATE_DATE from TABLENAME
WHERE CREATE_DATE > TO_DATE('2018-10-03', 'yyyy-mm-dd')
which causes this error

Code: Select all

Devart.Data.Oracle.OracleException (0x80004005): ORA-00932: inconsistent datatypes: expected NUMBER got DATE
We've just purchased a licence but this is going to be a bit of an awkward thing to work around. Can anyone help us out?

Thanks

Re: OracleException when using custom valueconverter

Posted: Mon 15 Oct 2018 14:23
by Shalex
Thank you for your report. We will investigate the issue and notify you about the result.

Re: OracleException when using custom valueconverter

Posted: Thu 29 Nov 2018 13:30
by Shalex
The bug with comparing columns, that use a value converter, to parameters and constants in EF Core 2 is fixed: viewtopic.php?f=1&t=38123.