You're close. The following will select PID
, CID
and Text
for each child, and PID
, CID = -1
and Text = "[[Empty]]"
for each parent with no children:
var source = lParent.GroupJoin(
lChild,
p => p.PID,
c => c.PID,
(p, g) => g
.Select(c => new { PID = p.PID, CID = c.CID, Text = c.Text })
.DefaultIfEmpty(new { PID = p.PID, CID = -1, Text = "[[Empty]]" }))
.SelectMany(g => g);