ValueTypes

Persistent fields can be of any ValueType. In this case NDO tries to store all public ValueType fields, as long as they are of a storable type. Public Properties are also stored if they allow both read and write access. This applies to system types and self defined types as well. The fields of ValueTypes are stored in the table of the owner class.

Dirty State Management

NDO cannot detect if members of ValueTypes are changed. Only the assignment of a ValueType to a field can be detected.

Parent.Point.X = 5;      // Is not detected
Parent.Point = newPoint; // Is detected

Furthermore assignments to a newly created ValueTypes cannot be detected because of the special ValueTypes conversion into the .NET Intermediate Language.

// Is not detected
Parent.Point = new System.Drawing.Point(5, Parent.Point.Y);

In this situation you either need an intermediate variable or you have to explicitly declare the object status as dirty. The resulting code is:

System.Drawing.Point newPoint = new System.Drawing.Point(5, Parent.Point.Y);

Parent.Point = newPoint;  // is detected

or:

Parent.Point = new System.Drawing.Point(5, Parent.Point.Y);

ObjectHelper.MarkDirty(Parent);  // is detected

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