I recently upgraded from EF7 to EF8, and because I do scaffolding models from DB (DB first approach), now I have DateOnly data types instead of DateTime for the Date column.
The problem I have is that now I cannot compare DateOnly and DateTime inside the where statement because the compiler thinks it’s two different types.
How can I resolve this?
var a = await DBContext.TableA.Where(u => u.DateTimeColumn != u.DateOnlyColumn).ToArrayAsync();
Where DateTimeColumn is DateTime in the model and SQL and DateOnlyColumn is DateOnly? (Nullable) in the model and Date (Nullable) in SQL.
If I’m comparing a SQL column and a parameter, I convert the DateTime parameter to DateOnly before the query, but I have a problem comparing two columns (DateTime and Date).