Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 1.56 KB

File metadata and controls

58 lines (44 loc) · 1.56 KB
layout default
sidebar classes
title SqlServerTableHints
description A class that contains all the SQL Server table optimizers.
permalink /class/sqlservertablehints
tags
repodb
sqlservertablehints
parent CLASSES

SqlServerTableHints


This class contains the list of table hints that is useful for SQL Server. It is usually used as passing parameter to the hints argument of most operations.

Usability

To use the hints, simply pass the target hints you want to use.

Below is a sample for querying the dirty records.

using (var connection = new SqlConnection(connectionString))
{
    var person = connection.QueryAll<Person>(hints: SqlServerTableHints.NoLock);
}

Or only reading the commited records.

using (var connection = new SqlConnection(connectionString))
{
    var person = connection.QueryAll<Person>(hints: SqlServerTableHints.ReadPast);
}

Also, below is a sample to lock the table during insertion.

using (var connection = new SqlConnection(connectionString))
{
    var id = connection.Insert<Person>(person, hints: SqlServerTableHints.TabLock);
}

Or during the Update operation.

using (var connection = new SqlConnection(connectionString))
{
    var id = connection.Update<Person>(person, hints: SqlServerTableHints.TabLock);
}

{: .note }

The class contains a lot of hints, we recommend that you visits the official Microsoft documentation for further understanding.