Linq的LEFT JOIN和RIGHT JOIN方案

Linq只有join,就是inner join啦,只有用如下方案:

var result = from p in snsDC.NT_User
                         join q in snsDC.NT_Photo on p.Portrait equals q.PhotoID into pq
                         from r in pq.DefaultIfEmpty()
                         where userIDs.ToArray().Contains(p.UserID.ToString())
                         select new { p.UserID, p.UserName, r.FilePath };

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注