0

I am having the problem that EntityFramework cannot convert DateTime.Date to SQL. I followed what other answers say about this problem (specific error: The specified type member 'Date' is not supported in LINQ to Entities.) but still the problem is happening. What am I missing?

var todayChanges = kbEntities.Changelogs.Where(c =>
                    EntityFunctions.TruncateTime(c.creationdate) == DateTime.Now.Date &&
                    (c.name == ChangelogBL.ChangeLogName.ChangedKB.ToString() ||
                     c.name == ChangelogBL.ChangeLogName.Imported.ToString())).ToList();
Tarta
  • 1,729
  • 1
  • 29
  • 63
  • 1
    Are you using EF6 or earlier versions? If EF6, please take a look at [this comment](https://stackoverflow.com/a/33340270/2590375) – nilsK Jul 25 '19 at 11:32
  • 2
    You either need to set `DateTime.Now.Date` to a variable and use that or you have to use `EntityFunctions.TruncateTime` on `DateTime.Now`. – juharr Jul 25 '19 at 11:36

0 Answers0