QueryExpression.NoLock Property

Definition

Gets or sets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query.

public:
 property bool NoLock { bool get(); void set(bool value); };
[System.Runtime.Serialization.DataMember(Order=50)]
public bool NoLock { get; set; }
[<System.Runtime.Serialization.DataMember(Order=50)>]
member this.NoLock : bool with get, set
Public Property NoLock As Boolean

Property Value

Boolean

Type: Booleantrue if there are no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query; otherwise, false.

Attributes

Remarks

The benefit of setting NoLock to true is that it allows you to keep the system from issuing locks against the entities in your queries; this increases concurrency and performance because the database engine does not have to maintain the shared locks involved. The downside is that, because no locks are issued against the records being read, some "dirty” or uncommitted data could potentially be read. A "dirty" read is one in which the data being read is involved in a transaction from another connection. If that transaction rolls back its work, the data read from the query using NoLock will have read uncommitted data. This type of read makes processing inconsistent and can lead to problems.

Applies to