Page 1 of 1

WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Wed 04 Dec 2019 16:44
by bairog
Hello.
I use dotConnect for SQLite 5.14.1519 and EF 6.2.
My database has DateTime field with milliseconds like following:
Image

And I'm selecting items that are for example < DateTime.Parse("06.11.2019 1:00:00.020") and >= DateTime.MinDate.
When I select them using WHERE clause in Linq to Entities it works incorrectly and return me 1 item,
when cast ToList() first and then use WHERE clause in Linq to Objects - it works correctly and return me 2 items.

Code: Select all

//values is IQueryable<>
//maxDate is for example DateTime.Parse("06.11.2019 1:00:00.020")
//minDate is for example DateTime.MinDate

//WHERE INSIDE LINQ TO ENTITES IS NOT WORKING CORRECTLY (1 VALUE IS RETURNED INSTEAD OF 2)
var summableFieldsList1 = values.Where(v => (v.HistoricalMomentDate.CompareTo(maxDate) < 0) && (v.HistoricalMomentDate.CompareTo(minDate) >= 0)).ToList();

//CAST TO LIST FIRST AND THEN WHERE INSIDE LINQ TO OBJECTS IS WORKING CORRECTLY (2 VALUES ARE RETURNED)
var summableFieldsList = values.ToList().Where(v => (v.HistoricalMomentDate.CompareTo(maxDate) < 0) && (v.HistoricalMomentDate.CompareTo(minDate) >= 0)).ToList();
DbMonitor cannot help me because it doesn't show milliseconds on Parameters tab.
Image

I've uploaded my code to run as-is here - line 120 ans 123 in SysTypesDB.SQLITE.EF\LogBookStorage.cs. Sorry for too much code - just copy-pasted a part from my project :).

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Fri 06 Dec 2019 19:10
by Shalex
Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Sat 07 Dec 2019 05:29
by bairog
Shalex wrote: Fri 06 Dec 2019 19:10 Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.
Thank you, waiting for a solution ASAP.

P.S. If it's possbile - update DbMonitor as well to show milliseconds for a DateTime on Parameters tab. It will be very helpfull for debugging in future. Many thanks.

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Thu 09 Jan 2020 07:32
by bairog
Shalex wrote: Fri 06 Dec 2019 19:10Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.
Happy new year and merry christmas.
Any progress for now? More than a month has passed..

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Thu 16 Jan 2020 15:12
by Shalex
Merry Christmas and Happy New Year!
The investigation is in progress. As soon as we have any results, we will contact you.

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Fri 21 Feb 2020 04:55
by bairog
Hello again.
Any progress for now - maybe in latest build (v.5.15.1583)?

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Tue 25 Feb 2020 16:24
by Shalex
The issue has been fixed.
maybe in latest build (v.5.15.1583)?
No, the fix was implemented after releasing the public build. Contact us and specify your email used when registering the product for getting the internal build.

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Thu 27 Feb 2020 06:06
by bairog
Shalex wrote: Tue 25 Feb 2020 16:24No, the fix was implemented after releasing the public build. Contact us and specify your email used when registering the product for getting the internal build.
I've obtained and tested internal build (5.15.1587) - everything is working as expected. Looking forward for a public build.

P. S. If it's possbile - please update DbMonitor as well to show milliseconds for a DateTime on Parameters tab. It will be very helpfull for debugging in future. Many thanks.

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Thu 27 Feb 2020 12:13
by Shalex
please update DbMonitor as well to show milliseconds for a DateTime on Parameters tab. It will be very helpfull for debugging in future.
We will notify you when the issue is fixed.

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Sat 04 Apr 2020 12:50
by Shalex
The bug with comparing milliseconds of DateTime properties is fixed in v5.15.1612: viewtopic.php?f=29&t=40463.

Re: WHERE clause compares dates with milliseconds incorrectly (EF6 Code-First)

Posted: Mon 21 Sep 2020 16:26
by Shalex
The Devart.Common.DbMonitor class is improved: now values of the DateTime parameters sent to the dbMonitor tool are supplemented with milliseconds: viewtopic.php?f=29&t=42250.