Fluent NHibnerate mapping question (one to one or none)
I am confused with how to do the following. I have
Ta开发者_运维知识库ble A
datetime AsOfDate PK
varchar Id PK
other irrelevant fields
Table B
datetime AsOfDate PK
varchar Id PK
other irrelevant fields
The relationship from A to B is (AsOfDate, Id) -> (AsOfDate, Id)
Every A has one or none B. Every B has one A.
In the mapping for A -> B is this HasMany, HasOne, References? In the mapping for B -> A is this HasOne?
Yes this is a HasOne since they both share a mutually exclusive primary key. Here is an example of a HasOne:
http://brunoreis.com/tech/fluent-nhibernate-hasone-how-implement-one-to-one-relationship/
Also take a look at this popular post about how to identify a true one to one relationship:
http://jagregory.com/writings/i-think-you-mean-a-many-to-one-sir/
精彩评论