0
我有以下的數據庫,我想在功能NHibernate創建映射,這樣我可以穿越像多列功能NHibernate映射
survey.question.feedback對象集合去問題的所有響應..如何我可以這樣做嗎?
我有以下映射到目前爲止
public class SurveyMapping : ClassMap<Survey>
{
public SurveyMapping()
{
Id(x => x.Id, "SurveyId");
Map(x => x.Name);
Map(x => x.Type);
Map(x => x.CreationDate);
Map(x => x.ModificationDate);
HasManyToMany<SurveyQuestions>(x => x.Questions).Table("Survey-Questions")
.ParentKeyColumn("SurveyId").ChildKeyColumn("QuestionId").Cascade.All();
HasManyToMany<User>(x => x.Users).Table("User-Surveys").ParentKeyColumn("SurveyId").ChildKeyColumn("UserId").Cascade.None();
}
}
public class SurveyQuestionsMapping : ClassMap<SurveyQuestions>
{
public SurveyQuestionsMapping()
{
Table("Questions");
Id(x => x.Id, "QuestionId");
Map(x => x.QuestionText);
Map(x => x.CommentText);
Map(x => x.Type);
Map(x => x.Scale);
Map(x => x.Rating);
Map(x => x.Threshold);
Map(x => x.CreationDate);
Map(x => x.ModificationDate);
HasMany<UserSurveyFeedback>(x => x.Feedback)
.KeyColumn("QuestionId");
**// This is the confusing part How I can load feedback associated with specific user here**
}
}
謝謝里卡多您的答覆。我不知道如何創建從用戶到反饋和問題到反饋的多對多映射,因爲我需要考慮來自反饋表 – Paresh
的(surveyID,QuestionID,UserID)列的組合。我還需要用戶對特定調查的反饋和問題..類似User.Survey [0] .Question [0] .Feedback – Paresh
沒有FNH它非常簡單。給我一天,我會嘗試拿出一個工作的例子。 –