我有一个实体:
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
?