NHibernate mapping with inheritance inheritance model

I am just starting with NHibernate and am trying to do a mapping for my model. (this is a model-based approach, TDD, just creating a database)

My hierachy class is something like:

My class hierachy

I'm trying to figure out how to do this now using an XML mapping file?

This is my table and what I want them to display on

QuestionId - Int - [Question.Id]

PmqccFormId - Int - [Question.PmqccForm.Id]

The answers entered are Int - [NormalQuestion.InputtedAnswer or JobVelocityQuestion.InputtedAnswer - both of these enumerations, which will be converted to / from ints, can separate them into separate columns, if necessary]

ResponsibleStaffId -Int - [PiAlertQuestion.ResponsibleStaffMember.Id]

Explanation - varchar - [Question.Explanation]

QuestionType - varchar - []

, , , . "", YesNoQuestion NormalQuestion, , .

, Question, ? - JobVelocityQuestion, . - ?

0
1

:

<class name="Question">
  ...
  <discriminator column="QuestionType"/>
  <subclass name="JobVelocityQuestion">
    <property name="InputtedAnswer"/>
  </subclass>
  <subclass name="NormalQuestion">
    <property name="InputtedAnswer"/>
    <subclass name="AsConsQuestion"/>
    ...
  </subclass>

, . .

+1

Source: https://habr.com/ru/post/1765017/


All Articles