NHibernate one to one versus 2 many-to-one

On his blog, Ayende suggests that using one-to-one is probably not the best way to implement a traditional 1: 1 object (e.g. customer.Name == name.Customer).

  • How to choose when to use a one-to-one relationship?
  • Why should I choose 2 one-to-many relationships
  • How one-to-one works (no FK columns)

One to one:

One-to-one

2 many-to-one:

enter image description here

+5
source share
1 answer

The only reason I came across using one-to-many comparisons is performance.

" ", . - , . . A, ( ) B . A, , B. . , , , . , ,

if (entityA.EntityB == null) HandleNoEntityB();

" ", , , .

if (entityA.EntitiesB.Count == 0) HandleNoEntityB();

, , A B. contrained = "true" .

+2

All Articles