I am using ef4 code first with a generic repository. My repository has a select method that looks like this:
public IEnumerable<T> Select(Func<T, bool> predicate)
{
return objectSet.Where(predicate);
}
I am calling it with the following code
pushQueueRepository.Select(x => x.User.ID == user.ID && x.PageID == pageID);
*note - pushQueueRepository has been properly instantiated.
When I run this I am getting a NullReferenceException. When I look at it in debug after the exception is thrown it shows the error being x.User.ID == user.ID. When I mouse over x.User it is null. However when I expand x there us a User object in x.User (not null) that does have an id.
FYI x is a PushQueue object that is defined as such:
public class PushQueue : IEntity
{
...
[Required]
public User User { get; set; }
...
}
This doesn't seem right, am I missing something?
Thanks.