映射非所需的對象我有一個複合對象建立項目 - >評價,我評議對象有哪些不需要ApprovedMentor對象,但是當我去保存項目Nhib罰球和錯誤說ApprovedUser有未被設置。但沒有設置,因爲它不是必填字段。我如何使用流暢的自動映射來設置它,這有可能嗎?功能NHibernate使用自動映射
public class MentoringProject : BaseEntity
{
public MentoringProject()
{
Appraisal = new Appraisal();
}
[NotNullNotEmpty]
[Length(Min=25, Max=1000)]
public virtual string Description { get; set; }
[Length(Min=25, Max=1000)]
public virtual string SupportRequired { get; set; }
[NotNullNotEmpty]
public virtual System.DateTime? DateSubmitted { get; set; }
[NotNullNotEmpty]
public virtual System.DateTime? ClosingDate { get; set; }
[NotNullNotEmpty]
[Size(Min=1)]
public virtual short Duration { get; set; }
[NotNullNotEmpty]
public virtual string Skills { get; set; }
public virtual Appraisal Appraisal { get; set; }
}
public class Appraisal : BaseEntity
{
public Appraisal()
{
ShortlistedMentors = new List<User>();
ApprovedMentor = new User();
College = new RefData();
}
#region Primitive Properties
public virtual bool Decision { get; set; }
public virtual System.DateTime? ApprovedDate { get; set; }
public virtual System.DateTime? AcceptedDate { get; set; }
public virtual System.DateTime? CompletionTargetDate { get; set; }
public virtual string RejectionReason { get; set; }
#endregion
#region Navigation Properties
public virtual IList<User> ShortlistedMentors { get; set; }
public virtual User ApprovedMentor { get; set; }
public virtual RefData College { get; set; }
#endregion
}
是User類的實體? – Vadim 2011-01-05 01:48:54
是的,它是。我將其連接到各種對象的域模型中,像MentoringProject.AddedUser,MentoringProject.UpdatedUser的ShortlistedMentors也是用戶對象的集合,我想我應該只是確保ApprovedUser設置爲空時,我打電話救? – Simon 2011-01-05 07:34:06