entity framework - Compare the value of 2 rows in 1 query -
i have table structure this:
userid int login_date datetime logout_date datetime login_status varchar(10)
the requirement retrieve top 2 rows particular userid sorted login_date asc. compare 2 login_date records , check if less 5 minutes.
can done in single linq statement?
thanks parameswaran
something should work (untested)
bool isrecentlogin = db.users .orderby(u => u.login_date) .take(2) .all(u => u.login_date.addminutes(5) < datetime.now);
Comments
Post a Comment