我有2个简单的列表:
当我尝试这样的简单查询时,我的代码返回null:
var linq = from s in mojUser
from us in mojDev
// join us in mojUser on s.DeviceId equals us.UserId
where s.UserId==us.DeviceId
select new
{
user = s.UserMac
}
答案 0 :(得分:1)
尝试
var linq = from s in mojUser
join us in mojDev on s.UserId equals us.DeviceId
select new
{
user = s.UserMac
}
答案 1 :(得分:0)
您缺少join
语句;
var linq = from s in mojUser
join us in mojDev on s.UserId==us.DeviceId
select new
{
s.UserMac
}
或使用扩展方法:
var linq = mojUser.Join(mojDev,
s => s.UserId,
us => us.DeviceId,
(s, us) => new { s.UserMac });