The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

OptimisticLockingAttribute Class

Specifies that a persistent object's state can be locked during a session.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.1.dll

Declaration

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = true)]
public sealed class OptimisticLockingAttribute : Attribute
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=True)>
Public NotInheritable Class OptimisticLockingAttribute
    Inherits Attribute
    Implements
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = true)]
public sealed class OptimisticLockingAttribute : Attribute
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=True)>
Public NotInheritable Class OptimisticLockingAttribute
    Inherits Attribute
    Implements

Remarks

The OptimisticLockingAttribute attribute specifies whether a session can lock a persistent object's state (allows optimistic locking to be enabled). To control object locking for objects that have the object locking option enabled, a new system field called by default OptimisticLockField is added to the object table's structure during the database schema update.

In optimistic concurrency, locks are set and held only while the data store is being accessed. The locks prevent other users from attempting to update objects at the same time. When an update is attempted, the original version of a changed object is compared against the existing object in the data store. If the two are different, the update fails with a concurrency error. It is up to you at that point to reconcile the two objects using your business logic.

Use the Session.LockingOption property to control the persistent object's locking during a session.

Use the Session.TrackPropertiesModifications property to enable field-level locking.

For more information, see Optimistic Concurrency Control.

Note

This attribute affects service member generation (see When and Why XPO Extends the Database Schema). If it needs to be applied to a dynamically created class, pass this attribute in the XPDictionary.CreateClass method arguments instead of adding it afterwards.

Inheritance

Object
Attribute
OptimisticLockingAttribute

Implements

See Also