efcore: SQLite : Datetime equality comparison not working (in memory)

When comparing exact dates in memory with the sqlite provider, it returns no result:

 var targets =  (from i in context.Whatever
                        where i.Date == myDate
                        select new { i.Id  }).ToList();

targets.Count is zero. But this works and returns one item:

 var targets =  (from i in context.Whatever
                        where i.Date.CompareTo(myDate)==0
                        select new { i.Id  }).ToList();

I use Microsoft.EntityFrameworkCore.Sqlite 1.1.2.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (13 by maintainers)

Most upvoted comments

@jjxtra Precision and readability

Thank you, it’s working with the 2017-08-21 00:00:00 format, the == comparison retrieves the item now.

Ah, .FFFFFFF won’t pad with 0s. You need to specify just 2017-08-21 00:00:00 in the SQL script.