我正在使用NHibernate和Fluent来制作映射和类。我有Survey和Question类(不需要答案)。问题在于该问题随调查为空。
public class Survey
{
public virtual string Description { get; set; }
public virtual IList<Question> Questions { get; set; }
}
public class Question
{
public virtual string Description { get; set; }
public virtual IList<Answer> Answers { get; set; }
public virtual Survey Survey { get; set; }
}
public class SurveyMap
{
public SurveyMap(): ClassMap<Survey>
{
Id(t => t.ID);
Map(c => c.Name);
Map(r => r.Description);
Map(e => e.Exclusion);
HasMany(f => f.Questions).Cascade.All().Inverse().Not.KeyNullable();
}
}
public class QuestionMap
{
public QuestionMap(): ClassMap<Question>
{
Id(t => t.ID);
Map(c => c.Name);
Map(r => r.Description);
//HasMany(r => r.Answers).Cascade.AllDeleteOrphan().Not.KeyNullable();
References(s => s.Survey).Cascade.All();
}
}
The Question Entity inside the Survey entity
上图显示该调查为空。
映射有什么问题?
我已经尝试过只在孩子身上放Reference(x => x.Survey);
。