Embedded Types

NDO treats the persistent fields of all classes that are not storable types as embedded types. All fields of these types are stored in the table of the parent object (the owner) if they are storable types (otherwise they are ignored). Embedded types are primarily used to add additional logic to the storable types, for example validation functions, length tests and such things. Objects of system types can be stored as Embedded Objects too.

Dirty State Management

NDO cannot detect changes of Embedded Type members. Hence it is recommended to code embedded types as so-called immutable types. Every operation that would change the state of an immutable object creates a new object. The string class in .NET is an immutable type.

NDO is able to set the persistence state of the owner to Persistent.Dirty when a new object is assigned to the filed of an embedded type.

If you cannot avoid changing the state of embedded objects, you directly have to set the status of the owner class to Persistent.Dirty. The ObjectHelper class of NDO is used for that:

  // Embedded Object is changed

Parent.Embedded.member = newValue;

// Set parent object to changed


Please see chapter Object States and Life Cycle for details on object states.

Transient Fields

The attribute [NDOTransient] allows defining certain fields of an embedded type as not persistent. Of course this option is only available for your custom defined types.