My Query as Follows
`Select * from daps_user_activity where Userid In (Select Userid from daps_portaluser where EMR_ID = 24855) `
What is the equivalent query in linq please help me...
My Query as Follows
`Select * from daps_user_activity where Userid In (Select Userid from daps_portaluser where EMR_ID = 24855) `
What is the equivalent query in linq please help me...
Try this, it's better that you use a join
in this instance, instead of a sub-query:
var results = (from a in daps_user_activity
join u in daps_portaluser on a.Userid equals u.Userid
where u.EMR_ID == 24855
select a).ToList()
Alternatively, you could use this:
var results = (from a in daps_user_activity
from u in daps_portaluser
where u.EMR_ID == 24855
&& a.Userid == u.Userid
select a).ToList()
To me, it shows more clearly the main query and the subquery.
Credit goes to @Bruno Brant at Convert SQL Query (with Correlated Subquery) to LINQ in C#