OracleException when using custom valueconverter

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
domrin
Posts: 4
Joined: Fri 10 Aug 2018 09:55

OracleException when using custom valueconverter

Post by domrin » Thu 11 Oct 2018 07:36

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: OracleException when using custom valueconverter

Post by Shalex » Mon 15 Oct 2018 14:23

Thank you for your report. We will investigate the issue and notify you about the result.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: OracleException when using custom valueconverter

Post by Shalex » Thu 29 Nov 2018 13:30

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.

Post Reply