Obtain the specified lock level upon the given object.

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll) Version: 3.2.0.4000 (3.2.0.4000)

Syntax

C#
void Lock(
	string entityName,
	Object obj,
	LockMode lockMode
)
Visual Basic
Sub Lock ( _
	entityName As String, _
	obj As Object, _
	lockMode As LockMode _
)
Visual C++
void Lock(
	String^ entityName, 
	Object^ obj, 
	LockMode^ lockMode
)

Parameters

entityName
Type: System..::..String
The Entity name.
obj
Type: System..::..Object
a persistent or transient instance
lockMode
Type: NHibernate..::..LockMode
the lock level

Remarks

This may be used to perform a version check (Read), to upgrade to a pessimistic lock (Upgrade), or to simply reassociate a transient instance with a session (None). This operation cascades to associated instances if the association is mapped with cascade="lock".

See Also