Lamdad
var categorizedProducts = product
.Join(productcategory, p => p.Id, pc => pc.ProdId, (p, pc) => new { p, pc })
.Join(category, ppc => ppc.pc.CatId, c => c.Id, (ppc, c) => new { ppc, c })
.Select(m => new {
ProdId = m.ppc.p.Id, // or m.ppc.pc.ProdId
CatId = m.c.CatId
// other assignments
});
Linq
var custs = from c in db.T_Customer
join u in db.Sys_User on c.OwnerId equals u.Id into temp
from t in temp.DefaultIfEmpty() //left join
where (c.PhoneNum1 == phone || c.PhoneNum2 == phone || c.PhoneNum3 == phone)
select new
{
CustName = string.IsNullOrEmpty(c.CustName) ? "匿名" : c.CustName,
UserName = t == null ? "暂无" : t.Name//这里主要第二个集合有可能为空。需要判断
};