Set the read-only mode for entities (and proxies) loaded by this query. This setting overrides the default setting for the session (see DefaultReadOnly).

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

Syntax

C#
public IQuery SetReadOnly(
	bool readOnly
)
Visual Basic
Public Function SetReadOnly ( _
	readOnly As Boolean _
) As IQuery
Visual C++
public:
virtual IQuery^ SetReadOnly(
	bool readOnly
) sealed

Parameters

readOnly
Type: System..::..Boolean
If true, entities (and proxies) loaded by the query will be read-only.

Return Value

this (for method chaining)

Implements

IQuery..::..SetReadOnly(Boolean)

Remarks

Read-only entities can be modified, but changes are not persisted. They are not dirty-checked and snapshots of persistent state are not maintained.

When a proxy is initialized, the loaded entity will have the same read-only setting as the uninitialized proxy, regardless of the session's current setting.

The read-only setting has no impact on entities or proxies returned by the criteria that existed in the session before the criteria was executed.

See Also