Utilize Entityfunctions or Dbfunctions for such an expression:
Difference is Dbfunctions is in System.Data.Entity.DbFunctions
and is for version 6+ of the Entity Framework, below use Entityfunctions who is in System.Data.Objects.EntityFunctions
In the specific case use DbFunctions.TruncateTime
or EntityFunctions.TruncateTime
depending on the version of Entity Framework
for it to leave only the value of Date. Also in your variable you put 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 that link, has a very similar but using another method. This link server with reference item.
Pnet this is duplicate: http://answall.com/questions/14857/erro-ao-passar-adddays-expression-lambda/14862#14862 look I already answered this!
– user6026
It is not duplicate, Harry. Because here I would like to know how I pass only the Date field without the hour part. There speaks of something else, although with date fields.
– pnet
All right then, but, let’s see how the community will understand this... by me all right, and the answer was given!
– user6026