LINQ Left Outer Join

Linq Left Outer Join

var result = from a in dc.TABLEA.ToList()
join b in dc.TABLEB
on a.Title equals b.Title
into joined
from b in joined.DefaultIfEmpty()
select new
{
a.ImageUrl,
a.AlternateText,
a.ToolTip,
headline = (b == null ? string.Empty : b.Headline),
content = (b == null ? string.Empty : b.Description)
};

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s