1
I have 3 related tables: Lesson (Id (PK), Name) Lessonquestion (Id (PK), Lessonid(FK), Title) Lessonquestionanswer (Id (PK), Lessonquestionid(FK), Value)
My Model:
public class Lesson : Entity
{
public virtual String Name { get; set; }
public virtual IList<LessonQuestion> Questions { get; set; }
}
public class LessonQuestion : Entity
{
public virtual String Title { get; set; }
public virtual IList<LessonQuestionAnswer> Answers { get; set; }
}
public class LessonQuestionAnswer: Entity
{
public virtual String Value { get; set; }
}
My Mapping:
public LessonMap()
{
Id(s => s.Id);
Map(s => s.Name).Not.Nullable();
HasMany(s => s.Questions)
.Cascade.All()
.Table("LessonQuestion")
.KeyColumn("LessonId")
.Component(s => { s.Map(x => x.Title); });
}
public LessonQuestionMap()
{
Id(s => s.Id);
Map(s => s.Title).Length(1000).Not.Nullable();
HasMany(s => s.Answers)
.Cascade.All()
.Table("LessonQuestionAnswer")
.KeyColumn("LessonQuestionId")
.Component(s => { s.Map(x => x.Value); s.Map(x => x.IsRight); });
}
public LessonQuestionAnswerMap()
{
Id(s => s.Id);
Map(s => s.Value).Length(1000).Not.Nullable();
}
When I run the List I get the following:
{
"data": {
"count": 1,
"offset": null,
"limit": null,
"entries": [
{
"name": "Aula1",
"questions": [
{
"title": "Title Question 1",
"answers": null,
"identifier": null
},
{
"title": "Title Question 2",
"answers": null,
"identifier": null
}
],
"identifier": "6670147eddd74d5cb51af9032afa9339"
}
]
}
}
I have record in Lessonquestionanswer table related to the "Title Question 1" record, but it is not loaded.
Does anyone know what might be going on?