How toPerform a left join in linq pad -
left-join, linq-to-sql, linqpad
Solution
In your anonymous type, make sure your ints are returning ints.
Change
StyleHeaderId = c.Id,
To
StyleHeaderId = (c.Id == null ? 0 : c.Id),
Problem
How can I get linq pad to run my left join as show below? ``` var query = from s in db.CDBLogsHeaders .OrderByDescending(g => g.LogDateTime) from sc in db.StyleColors .Where(stylecolor => stylecolor.id == (int?)s.StyleColorID) .DefaultIfEmpty() from c in db.StyleHeaders .Where(styleHeader => styleHeader.id == (int?)s.StyleHeaderID) .DefaultIfEmpty() select new { CDBLogsHeaderId = s.Id, Merchandiser = c.Merchandiser, Material = s.Material, Season = s.Season, LogsHeaderLogType = s.LogType, PushFromTo = s.PushFromTo, LinePlan = s.LinePlan, QuikRefNumber = s.QuikRefNumber, PLMOrigin = s.PLM_Origin, SeasonOriginal = c.SeasonOriginal, SeasonCurrent = c.SeasonCurrent, StyleHeaderId = c.Id, StyleCode = c.StyleCode, StyleColorsColorCode = sc.ColorCode }; query.Dump(); ``` The sql that linq pad creates runs perfectly in Management Studio but linq-pad doesn't display any rows and gives this error InvalidOperationException: The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type. How can I get linqpad to work so I can play with it?