LINQ-to-entities - Null reference

Posted by BlueRaja on Stack Overflow See other posts from Stack Overflow or by BlueRaja
Published on 2010-03-15T14:46:43Z Indexed on 2010/03/15 14:49 UTC
Read the original article Hit count: 351

Filed under:
|
|
|

I could swear this was working the other day:

var resultSet =
    (from o in _entities.Table1
     where o.Table2.Table3.SomeColumn == SomeProperty
     select o
    ).First();
SelectedItem = resultSet.Table2.SomeOtherColumn;

I am getting a null reference exception on the last line: resultSet.Table2 is null.
Not only am I sure that all the foreign keys and whatnot have the correct values, but I don't see how Table2 could be null, since o.Table2.Table3.SomeColumn == SomeProperty.

resultSet is being returned with all its properties set to the correct values, with the exception that Table2 is null.

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about linq-to-entities