0
我有一個包含用戶數據連接兩個表有兩個外鍵
Users(userID, name , email ,......)
和我哈瓦包含其它表的表:
在UserFriends表Userfriends(UserFriendID,Fk_UserSendReqID,FK_UserRecieveReqID,IsAccepted,....)
有連接兩個外鍵這張表與用戶表 我想寫一個查詢與LINQ選擇用戶的朋友userId=2
我寫這個查詢,但它是錯的
var n = from u in DataContext.Context.Users
join uf in DataContext.Context.UsersFriends
on u.UserID equals uf.UserSendReqID
join uf2 in DataContext.Context.UsersFriends
on u.UserID equals uf2.UserRecieveReqID
where (uf.UserSendReqID == 2|| uf.UserRecieveReqID == 2)
&& uf.IsAccepted == true
select new
{
name = u.FirstName + " " + u.LastName
};