Use EntityFunctions DbFunctions for such expression: / p>
Difference is that DbFunctions is in System.Data.Entity.DbFunctions
and is for version 6+ of the Entity Framework, below use EntityFunctions which is in System.Data.Objects.EntityFunctions
In the specific case, use DbFunctions.TruncateTime
or < a href="http://msdn.microsoft.com/en-us/library/system.data.objects.entityfunctions.truncatetime%28v=vs.100%29.aspx"> EntityFunctions.TruncateTime
depending on the version of Entity Framework
for it to leave only the Data value. Also in the variable its puts the value of Date equal var dta = DateTime.Now.Date;
also bringing only Date without time.
var dta = DateTime.Now.Date;
var resultado = db.T_PDV.Where(a => DbFunctions.TruncateTime(a.DataCadastro) == dta)
.Select(i => new { i.CNPJ})
.ToList();
var dta = DateTime.Now.Date;
var resultado = db.T_PDV.Where(a => EntityFunctions.TruncateTime(a.DataCadastro) == dta)
.Select(i => new { i.CNPJ})
.ToList();
In this link , you have one similar but using another method. This link server with reference item.