|
Article relates to
|
Telerik OpenAccess ORM
|
|
Created by
|
Alexander Filipov
|
|
Last modified
|
April 9, 2012
|
|
Last modified by
|
Pencho Popadiyn
|
DESCRIPTION
By default the OpenAccessContext 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 a certain element is changed. To notify the programmer for this behavior, Telerik OpenAccess ORM shows a warning at compile time with this limitation:
OpenAccess Warning: Explicit change tracking required for the array field Namespace.ClassName.FieldName
SOLUTION
When you change some value of an array, you will have to inform the context that you have made a changes, so that it can be persisted to the database.
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
OpenAccessContext.MakeDirty 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.
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.