开发者

SQL to LINQ Conversion in C#

开发者 https://www.devze.com 2023-01-12 04:15 出处:网络
Can 开发者_运维知识库anybody tell the equivalent LINQ syntax for this query in c#? SELECTUsers.UserName, UserStatus.StatusTitle, UserStatus.StatusDetails

Can 开发者_运维知识库anybody tell the equivalent LINQ syntax for this query in c#?

SELECT     Users.UserName, UserStatus.StatusTitle, UserStatus.StatusDetails
FROM UserStatus 
INNER JOIN  Users ON UserStatus.UserId = Users.UserID
where Users.userid=3 
OR users.userID in (
 SELECT     UserFriends.FriendId
 FROM Users 
 INNER JOIN UserFriends ON Users.UserID = UserFriends.UserId
 where Users.userid=3 )


(from status in UserStatus
join user in Users ON status.UserID equals user.UserID
where user.UserID == 3 ||
( from u in users
join friends in UserFriends on u.UserID equals friends.UserID where u.UserID == 3
select friends.FriendId).Contains(user.UserID)
select new {user.UserName, status.StatusTitle, status.StatusDetails});
0

精彩评论

暂无评论...
验证码 换一张
取 消