from a in m.Account
join ac in m.VwAccountConfirmation on a.AccountId equals ac.AccountId into acg
from acgitem in acg.DefaultIfEmpty()
where acgitem.AccountId == null
"acgitem.AccountId" is an int32 and its not nullable. So why is the compiler letting me compare it with null? (This query works)
acgitem.AccountId is a projected field (result of Join...Into...) that can accept null.
Example from Northwind:
var query= from c in db.Customers
join o in db.Orders on c.CustomerID equals o.CustomerID into sr
from x in sr.DefaultIfEmpty()
select new {CustomerID= c.CustomerID, ContactName=c.ContactName, OrderID = x.OrderID == null ? -1 : x.OrderID};
Also I'm getting a code hint or something for 'acgitem.AccountId == null' that may be Resharper and it says... 'Expression is always false'. I suppose an int32 is never going to be null - is this what it means?
Just ignore the resharper hint, as it seems that it can't evalute projectioned linq code correctly.
Your code is perfectly correct.