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

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

Syntax

C#
ICriteria SetReadOnly(
	bool readOnly
)
Visual Basic
Function SetReadOnly ( _
	readOnly As Boolean _
) As ICriteria
Visual C++
ICriteria^ SetReadOnly(
	bool readOnly
)

Parameters

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

Return Value

this (for method chaining)

Remarks

To set the default read-only setting for entities and proxies that are loaded into the session, see DefaultReadOnly.

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 has, 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