Relations of Cardinality n

These relations are implemented with the types IList, ArrayList, or List<T>.

The easiest way to implement a relation is to use the Add Relation wizard of NDO and Add Acessor button to create properties and functions for adding and removing of elements.

You can use your own list classes to implement List Relations. These classes have to comply with certain rules:

  • They should implement the non generic IList interface, even if they are generic types. If they are generic types they may implement the IList<T> interface too, as the List<T> class does. It’s recommended, to derive your own generic list classes from List<T>.
  • There may not be any additional methods which cause a change of the List content, because NDO would not be able to recognize these changes.
  • The classes should implement either IClonable or a constructor which accepts a list of the same type as parameter and constructs a clone of the list as result value.
  • The classes should have a default constructor (a constructor without arguments).

Note that NDO does not change your list classes in any way as it does not change the classes of the .NET framework. It can only detect the calls to certain methods of the list classes and intercept these calls in order to recognize any changes in the list content. If you change the semantics of the methods (for example, using the method Remove to add objects ;-) ), NDO would not be able to detect these changes.

Important: The Relation Management is only possible if adding and removing elements from the list happens inside the parent class. If a list is passed to the outside by a property and an element is added outside, this element cannot be stored as a child object. The same applies for the manipulation of lists via reflection. In both cases NDO cannot detect that elements are added.

In turn it works if a completely new list of child elements inside the class code is assigned to the relation field. The relation to the elements existing so far is dissolved and a relation to the new elements is constructed.