Linq, how to specify timestamp condition?

Posted by 5YrsLaterDBA on Stack Overflow See other posts from Stack Overflow or by 5YrsLaterDBA
Published on 2010-05-11T15:03:15Z Indexed on 2010/05/11 15:14 UTC
Read the original article Hit count: 246

Filed under:
|

I have a logins table which records all login and logout activities. I want to look at all login activities of a particular user within 24 hrs. how to do it? something like this:

var records = from record in db.Logins
                                where record.Users.UserId == userId
                                    && record.Timestamp <= (DateTime.Now + 24)
                                select record;

record.Timestamp <= (DateTime.Now + 24) is wrong here. I am using C# 3 + L2E.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ