I'm trying to get a data filtering only by date (truncating the time). The field in database is DateTime.
As reference, I tried this solution that didn't work: 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported where I should use the EntityFunctions that was replaced by DbFunctions, however, It still didn't work.
So I searched more trying to find some code that looks like mine, and then I've found this other link: Using DbFunctions I get error: The specified type member 'Date' is not supported in LINQ to Entities but I'm still getting the same error:
The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
Any suggestion?
My code:
var data = DateTime.Now.Date;
PostVisualizacoes visualizacao = db.PostVisualizacoes.Where(v => v.UsuId == usuario.UsuId && v.PosId == post.PosId && DbFunctions.TruncateTime(v.PosVisData.Date) == data).FirstOrDefault();