I have an Oracle database column of type date, the date format is dd-MMM-yy, when I try and retrieve an entity from the database using the Entity Framework and a date comparison I get back no records.
I use this method for the query
var calendar = _repository.Single<Calendar>(c => DbFunctions.TruncateTime(c.CALNDR_DATE) == DbFunctions.TruncateTime(calendardate));
I've also tried it in various ways:
var calendar = _repository.Single<Calendar>(c => c.CALNDR_DATE) == calendardate);
I thought this one would work for sure:
var calendar = _repository.Single<Calendar>(c => c.CALNDR_DATE.Year == calendardate.Year && c.CALNDR_DATE.Month == calendardate.Month && c.CALNDR_DATE.Day == calendardate.Day);
No matter what I've tried I cannot get the method to bring back a calendar record even though I have verified there is a record with the date I'm passing. The value in the calendardate variable is formatted as mm/dd/yyyy. If I query the database directly using SQLDeveloper I get back a result when I search with this query select * from table where CALNDR_DATE = '17-DEC-15'
But no result if I search for: select * from braidss.tmmis98 where CALNDR_DATE = '12/17/2015'
- This is what I see if I check what is generated by the LINQ
My question is how can I handle this comparison so the dates match? I have tried several different ways but nothing has worked so far.