0

Survey クラスと Poll クラスの 2 つのクラスがあります。また、質問と質問選択のクラスもあります。これらをどのようにマッピングすれば、特定のテーブル形式を作成できますか。関連するクラスは次のとおりです。

public class Survey
{
     public IList<Question> Questions { get; private set; }   
}

public class Poll
{
    public Question Question { get; set; }
}

public class Question
{
    public string Text { get; set; }
    public IList<QuestionChocie> Choices { get; private set; }
}

public class QuestionChoice
{
    public string Text { get; set; }
}

私が撮影している結果のテーブルには、次のものが含まれます

Surveys- a table of survey information.
Polls - a table of polls information.
SurveyQuestions -a table of survey questions.
PollQuestions - a table of poll questions.
SurveyChoices - a table of the question choices for the surveys.
PollChoices - a table of the question choices for the survey.

できれば、Fluent NHibernate について本当に知りたいか、xml をマッピングするだけでもかまいません。

4

1 に答える 1

0

テーブル間の関係を定義していないので、1対多を想定します。

一般的なマッピングは次のようになります。

public class SurveyMap : ClassMap<Survey>
{
    public SurveyMap()
    {
        HasMany<SurveyQuestion>(x => x.Questions).Inverse();
        // Rest of mapping
    }
}

public class SurveyQuestionMap : ClassMap<Question>
{
    public QuestionMap()
    {
        References<Survey>(x => x.Survey);
        HasMany<SurveyChoice>(x => x.Choices).Inverse();
        // Rest of mapping
    }
}

public class SurveyChoiceMap : ClassMap<SurveyChoice>
{
    public SurveyChoiceMap()
    {
        References<SurveyQuestion>(x => x.Question);
        // Rest of mapping
    }
}
于 2009-03-30T18:54:45.330 に答える