Part 19 UpdateCheck property

preview_player
Показать описание
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Slides

LINQ to SQL Tutorial - All Text Articles & Slides

LINQ to SQL Tutorial Playlist

Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses

This is continuation to Part 18. Please watch Part 18, before proceeding. UpdateCheck property of ColumnAttribute class is used to determine how LINQ to SQL detects concurrency conflicts.

This property can be set to one of the 3 values of the UpdateCheck enum. This enum is present in System.Data.Linq.Mapping namespace. The following are the different values of UpdateCheck enum and what they mean.

Always - Always use this column for conflict detection.
Never - Never use this column for conflict detection.
WhenChanged - Use this column only when the member has been changed by the application.

The default is Always. This means by default all the columns will be used to detect concurrency conflicts.

Example :
[global::System.Data.Linq.Mapping.ColumnAttribute
(Storage="_AccountBalance", DbType="Int", UpdateCheck=UpdateCheck.Never)]
public System.Nullable[int] AccountBalance
{
get
{
return this._AccountBalance;
}
set
{
if ((this._AccountBalance != value))
{
this.OnAccountBalanceChanging(value);
this.SendPropertyChanging();
this._AccountBalance = value;
this.SendPropertyChanged("AccountBalance");
this.OnAccountBalanceChanged();
}
}
}
3. Open SQL Profiler and run a new trace
4. Run the application and click "Deposit $500" button
5. Inspect the generate UPDATE SQL command.

exec sp_executesql N'UPDATE [dbo].[Accounts]
SET [AccountBalance] = @p2
WHERE ([AccountNumber] = @p0) AND ([AccountName] = @p1)',

Notice, that AccountBalance is removed from the WHERE clause, which means this column is not used for detecting concurrency conflicts.
Рекомендации по теме
welcome to shbcf.ru