In my Linq, I am trying to make an inner join to a nullable field. Employee and Department have a relation, Department may have an EmployeeID or may have a null. So what wou
I had the same issue, where my charge_codes.CompanyId was nullable but my order_items.CompanyId was NOT nullable.
So I had to get my charge codes into their own ananomous type and make it not be nullable.
var chargeCodes = from s in db.Charge_Codes
where s.CompanyID != null
select new { CompanyID = (int)s.CompanyID,
Charge_CodeID = s.Charge_CodeID,
Revenue_Code_Id = (int)s.Revenue_CodeID, };
//now my chargeCodes contains an anonymous with a non nullable CompanyID and
//a non nullable Revenue_CodeID
//use chargeCodes here
var query = from oi in db.Order_Items
join cc in chargeCodes on
new {oi.CompanyID, oi.Charge_CodeID} equals new {cc.CompanyID, cc.Charge_CodeID}