Lets say i have two entities;
QuestionAnswer(Id, AnswerValue)
Note(Id, QuestionAnswer_Id,开发者_开发问答 NoteValue)
How would I map this in Fluent Nhibernate? I know that there is a HasOne mapping but this is for a 1 to 1 unless im mistaken?
I could also map it as a 1 to M but would require aList<Note>
as a navigation property on my QuestionAnswer entity which again doesnt make much sence for a 1 or 0 to me.
Thanks, Kohan
I've struggled with this also. What I ended up doing is mapping a private collection and using public properties to control the number of elements in the collection. Basically I treat it as a 1..n collection instead of a 1..* collection where n = 1.
Use one-to-one association, and set the Note to null if it is not available.
Also, see Hibernate one to zero or one mapping.
精彩评论