I've got a query I need to perform:
return entity.Messages.Include(m => m.User) .Include(m => m.MessageRecipients.Select(u => u.User)) .First(m => m.MessageID == messageID); This works fine on my local machine but it breaks on the webserver, despite the same setup. The problem is that I try to include the User
Include(m => m.User)
but the user could not exist in the database anymore so it throws "Sequence contains no elements" because I use First().
Question: Is there a way to build the query in a way, so it does not brake when a user is not in DB? Something like outer join in SQL?
EDIT: If there's no User I still need the Message to be returned...