开发者

Fluent NHibnerate mapping question (one to one or none)

开发者 https://www.devze.com 2023-03-07 16:44 出处:网络
I am confused with how to do the following. I have Ta开发者_运维知识库ble A datetime AsOfDate PK

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消