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

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -