var leftFinal = from l in lefts join r in rights on l equals r.Left into lrs from lr in lrs.DefaultIfEmpty() select new { LeftId = l.Id, RightId = ((l.Key==r.Key) ? r.Id : 0 };