xpo-devexpress-dot-xpo-dot-session-93c06188.md
Gets or sets a value which specifies how XPO behaves when reloading changed objects (objects with different versions).
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
[DefaultValue(OptimisticLockingReadBehavior.Default)]
public OptimisticLockingReadBehavior OptimisticLockingReadBehavior { get; set; }
<DefaultValue(OptimisticLockingReadBehavior.Default)>
Public Property OptimisticLockingReadBehavior As OptimisticLockingReadBehavior
| Type | Default | Description |
|---|---|---|
| OptimisticLockingReadBehavior | Default |
An OptimisticLockingReadBehavior enumeration value that specifies how XPO behaves when reloading changed objects (objects with different versions).
|
Available values:
| Name | Description |
|---|---|
| Default |
The default behavior can be changed by setting the XpoDefault.OptimisticLockingReadBehavior property.
| | Ignore |
The changed objects are not reloaded.
| | ReloadObject |
The changed objects are automatically reloaded.
| | Mixed |
If a transaction has been started, the changed objects are not reloaded. Otherwise, the changed objects are automatically reloaded. For example, transaction starts after you modify objects in the session.
| | ThrowException |
An exception is thrown.
| | MergeCollisionIgnore |
When the client-side and database values of a property are different, the client-side value persists. When field-level tracking is disabled (see Session.TrackPropertiesModifications), this value is treated like Mixed.
| | MergeCollisionThrowException |
When the client-side and database values of a property are different, an exception is thrown. When field-level tracking is disabled (see Session.TrackPropertiesModifications), this value is treated like the Mixed.
| | MergeCollisionReload |
When the client-side and database values of a property are different, the database value is reloaded. When field-level tracking is disabled (see Session.TrackPropertiesModifications), this value is treated like Mixed.
|
The default value for OptimisticLockingReadBehavior is OptimisticLockingReadBehavior.Mixed. In this mode, XPO automatically reloads changed objects only if a transaction is not started. To determine the change, it reads the database’s OptimisticLock field value which is loaded with each query.
XPO allows you to disable automatic object reloading. It exposes two properties that control XPO’s behavior in such instances. These properties are: OptimisticLockingReadBehavior and XpoDefault.OptimisticLockingReadBehavior.
The Session.GetObjects method has the force parameter, which specifies whether to reload objects from a data store. When the force parameter is set to true, Session always reloads modified objects regardless of the OptimisticLockingReadBehavior option.
The following methods (and their async versions) set the force parameter to true: Session.Reload overloads.
The following methods (and their async versions) set the force parameter to false: Session.FindObject and XPBaseCollection.Load overloads.
XPQuery always calls the GetObjects method with the force parameter set to false.
See Also