NPersistence Reference Guide
Assembly: NPersistence (in NPersistence.dll) Version: 2.0.0.0 (2.0.0.0)
Lock an entity instance that is contained in the persistence
context with the specified lock mode type and with specified
properties.
If a pessimistic lock mode type is specified and the entity
contains a version attribute, the persistence provider must
also perform optimistic version checks when obtaining the
database lock. If these checks fail, the
OptimisticLockException will be thrown.
If the lock mode type is pessimistic and the entity instance
is found but cannot be locked:
Namespace: NPersistence- the PessimisticLockException will be thrown if the database locking failure causes transaction-level rollback
- the LockTimeoutException will be thrown if the database locking failure causes only statement-level rollback
Assembly: NPersistence (in NPersistence.dll) Version: 2.0.0.0 (2.0.0.0)
Syntax
C# |
void Lock( Object entity, LockModeType lockMode, Dictionary<string, Object> properties )
Parameters
- entity
- Object
entity instance
- lockMode
- LockModeType
lock mode
- properties
- Dictionary<(Of <(<'String, Object>)>)>
standard and vendor-specific properties and hints
Exceptions
Exception | Condition |
---|---|
System..::..ArgumentException | if the instance is not an entity or is a detached entity |
NPersistence..::..TransactionRequiredException | if there is no transaction |
NPersistence..::..EntityNotFoundException | if the entity does not exist in the database when pessimistic locking is performed |
NPersistence..::..OptimisticLockException | if the optimistic version check fails |
NPersistence..::..PessimisticLockException | if pessimistic locking fails and the transaction is rolled back |
NPersistence..::..LockTimeoutException | if pessimistic locking fails and only the statement is rolled back |
NPersistence..::..PersistenceException | if an unsupported lock call is made |