0
userid name email
1 venkat [email protected]
2 venu [email protected]
3 raghu [email protected]
合作伙伴:
id userid partnerid status
1 1 2 1
2 1 3 1
位置:
id userid lat lon
1 1 12.00 13.00
2 2 14.00 12.00
3 3 14.00 14.23
查詢:
var result = from partner in Partners
join user in Users on partner.UserId equals user.PartnerId
join location in Locations on patner.UserId equals location.PartnerId
where partner.UserId == 1
select new { PartnerId = partner.PartnerId, PartnerName = user.Name, Lat = location.Lat, Lon = location.Lon };
通過傳遞userid=1
作爲參數,我得到這個結果:
partnerid patnername lat lon
2 venkat 14.00 12.00
3 venkat 14.00 14.23
通過上述結果的觀察這裏partnernames是錯誤的partnerid = 2
- patname
是venu
但顯示 「venkat」
爲partnerid = 3
,合作伙伴名稱爲raghu
,但顯示venkat
。
如何顯示正確的合作伙伴名稱?