Association between two classes is a very simple concept to understand. If you want to have association between
ClassB, then you can add a property of type
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
Collectiontype. 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.