What I'm doing works, but it's just wrong, I know it.
public Profile GetProfile(int id)
{
Profile profile = (
from u in en.User where u.UserID == id
select u.Profile.FirstOrDefault()
).First();
if (profile.UserReference.Value == null)
profile.UserReference.Load();
return profile;
}
Profile.UserID is a FK tied to User.UserID. Thus, Profile.UserID is not included in the Entity Model by the Entity Framework, which is why my linq query looks up the User object first and then selects the related Profile object (which feels very dirty to me).
Can anyone offer a better solution to:
- Lookup the Profile object via User.UserID.
- Load the User object reference in the returned Profile object.
Thanks in advance!