|
Article relates to
|
Telerik OpenAccess ORM
|
|
Created by
|
Alexander Filipov
|
|
Last modified
|
October 22, 2009
|
|
Last modified by
|
Alexander Filipov
|
DESCRIPTION
By default the IObjectContext (implemented by the ObjectScope and ObjectContainer classes) silently manages the change tracking of the persistent objects. However, this is not possible for all types of fields that a class may contain. For example, changes in array fields could not be fully tracked by the object context. This limitation is present when an array field is not completely replaced with another array but only certain element is changed. To notify the programmer for this behavior, Telerik OpenAccess ORM shows a warning at compile time with the following text:
OpenAccess Warning: Explicit change tracking required for the array field Namespace.ClassName.FieldName
SOLUTION
The code below would not persist the change in the byte[] field named Picture from the Category object:
As the warning states, explicit change tracking is required in this case. This can be accomplished by using the
IObjectContext.MakeDirty(object persistentObject, string fieldname) method. It marks a field as “dirty”, thereby the field value is forced to be stored in the database. Below is the same sample code that modifies one of the array elements but this time the change is persisted. Note that the MakeDirty() method should be called before the change is made.
The case when the whole array is replaced with another array does not require any additional operations. The change tracking is done internally:
Please
Sign In
to rate this article.