Tables:
Users
userid username imageurl
1 venkat http://test.jpg
2 raghu http://test1.jpg
3 ravi http://test2.jpg
Friends
id userid frienduserid status
1 1 2 true
2 2 1 false
LogStatus
id userid sessionid
1 1 7482748
2 1 8274282
3 2 3123123
If I pass userid=1
then need to pull his friends username,imageurl,status
and any of his friends having at least one sessionid
then give status as "true".
As of I am able to join users, friends table giving his friends username,imageurl
and status
. But how to check any one of his having at least one sessionid
?
My query:
var result = from pa in cxt.Users
join us in cxt.Friends on pa.User_Id equals us.Friend_UserId
where us.User_Id == incID
select new
{
us.frienduserid,
pa.User_Name,
pa.ImageURL,
us.status
};
var result =
from user in cxt.Users
join friend in cxt.Friends on user.UserId equals friend.FriendUserId
where user.UserId == incId
select new
{
FriendUserId = friend.FriendUserId,
UserName = user.UserName,
ImageUrl = user.ImageUrl,
Status = cxt.LogStatus.Any(s=>s.UserId == user.UserId)
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.