QueryExpression.NoLock Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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.