Reputation: 1722
Can anyone tell me what could possible be wrong with the date comparison here?
No property 'Date' exists in type 'Edm.DateTime' at position 60 "reffering to s.SwipeDateTime.Value.Date"
var lastSwipe = (from s in this.DataWorkspace.ApplicationData.EmployeeSwipeLogs
where s.Employee.Id == emp.Id &&
s.SwipeIsValid == true &&
s.SwipeDateTime.Value.Date == DateTime.Today
orderby s.SwipeDateTime descending
select s).FirstOrDefault();
Upvotes: 1
Views: 298
Reputation: 3879
You may also find Entity Functions useful. These allow you to use some methods that you otherwise wouldn't be able to use.
You'll need to add:
Upvotes: 1
Reputation: 1722
If you are using Entity framework then you are right the EDM.DateTime does not have a .Date property. Check out EDM.DateTime for what methods you can use.
Upvotes: 1
Reputation: 1500675
Quite simply, the LINQ provider you're using probably doesn't support Convert.ToDateTime
. What's the type of s.SwipeDateTime
anyway? If it's already DateTime
, you shouldn't need to convert in the first place - and if it's not DateTime
, it probably should be. Note that you can use DateTime.Today
instead of DateTime.Now.Date
, and personally I'd move that to before the query.
Upvotes: 1