用户:
userid name email
1 venkat v@g.com
2 venu ve@g.com
3 raghu r@g.com
伙伴:
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
通过观察上述结果,这里的合作伙伴名称是错误的partnerid = 2
-patname
只是 venu
显示“venkat”
因为partnerid = 3
,partnernameraghu
只是显示venkat
。
如何显示正确的合作伙伴名称?