OracleException when using custom valueconverter
Posted: 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.
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
Then this is what is generated:
which causes this error
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
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);
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);
Code: Select all
SELECT CREATE_DATE from TABLENAME
WHERE CREATE_DATE > TO_DATE('2018-10-03', 'yyyy-mm-dd')
Code: Select all
Devart.Data.Oracle.OracleException (0x80004005): ORA-00932: inconsistent datatypes: expected NUMBER got DATE
Thanks