Reputation: 5914
I need to get the query of the day, the problem is that I'm getting an error when I try to compare the value that comes from the DB (which is a DateTime
), against the DateTime.Today.Date
value.
What I'm trying to achieve is to get the registers of the day.
List<Client> _cliente = from c in db.Cliente
join v in db.Vendedor
on c.IDVendedor equals v.IDVendedor
where v.Fecha.Date.Equals(DateTime.Today.Date)
This is what I'm getting: 'The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.'
Upvotes: 2
Views: 3189
Reputation: 70538
You can use the C# standard library -- There is a time interval type (subtract one time from another, then get the absolute value of the number of days, like so:
List<Client> _cliente = from c in db.Cliente
join v in db.Vendedor
on c.IDVendedor equals v.IDVendedor
where Math.Abs((v.Fecha.Date - DateTime.Today).Days) <= 1
Upvotes: 0
Reputation: 8372
Maybe you can do something like this:
var today = DateTime.Today;
var tomorrow = today.AddDays(1);
List<Client> _cliente = from c in db.Cliente
join v in db.Vendedor
on c.IDVendedor equals v.IDVendedor
where v.Fecha >= today && v.Fecha < tomorrow
Upvotes: 9