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

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

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