私はエンティティを持っています:
public virtual int RecommendedUserId { get; set; }
public virtual string Firstname { get; set; }
public virtual string Surname { get; set; }
public virtual string Email { get; set; }
public virtual string JobTitle { get; set; }
public virtual DateTime? DateAndTimeProcessed { get; set; }
public virtual DateTime? DateAndTimeRecommended { get; set; }
public virtual string ReasonForRejection { get; set; }
// User also an entity and has property UserId
public virtual User RecommendedByUser { get; set; }
public virtual User AssignedToUser { get; set; }
私のコントローラーには次のものがあります:
Entities.RecommendedUser user = new RecommendedUser();
user.Firstname = model.Firstname;
user.Surname = model.Surname;
user.Email = model.Email;
user.JobTitle = model.JobTitle;
// why am i getting the Object reference not set to
// an instance of an object error??
user.RecommendedByUser.UserId = CurrentUser.UserId;
インスタンス化する場合、内部でもRecommendedUser
インスタンス化しませんか??User
RecommendedUser