O'Reilly logo

Learning NHibernate 4 by Suhas Chatekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mapping associations

Association between two classes is a very simple concept to understand. If you want to have association between ClassA and ClassB, then you can add a property of type ClassB on ClassA. This is the most basic form of association.

Associations come in four different forms as described next:

  • One-to-many: One end of the association has single instance of the entity while the other end has multiple instances. In code, this is represented by a property of the Collection type. For example, IList<T>, [], ICollection<T> ,IEnumerable<T>. and so on
  • Many-to-one: Opposite of one-to-many.
  • One-to-one: Both ends of associations have one single instance of entities.
  • Many-to-many: Both ends of associations have multiple instances of entities.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required