Export (0) Print
Expand All

How to: Specify Which Members are Tested for Concurrency Conflicts

Apply one of three enums to the LINQ to SQL UpdateCheck property on a ColumnAttribute attribute to specify which members are to be included in update checks for the detection of optimistic concurrency conflicts.

The UpdateCheck property (mapped at design time) is used together with run-time concurrency features in LINQ to SQL. For more information, see Optimistic Concurrency: Overview.

Note Note

Original member values are compared with the current database state as long as no member is designated as IsVersion=true. For more information, see IsVersion.

For code examples, see UpdateCheck.

To always use this member for detecting conflicts

  1. Add the UpdateCheck property to the ColumnAttribute attribute.

  2. Set the UpdateCheck property value to Always.

To never use this member for detecting conflicts

  1. Add the UpdateCheck property to the ColumnAttribute attribute.

  2. Set the UpdateCheck property value to Never.

To use this member for detecting conflicts only when the application has changed the value of the member

  1. Add the UpdateCheck property to the ColumnAttribute attribute.

  2. Set the UpdateCheck property value to WhenChanged.

The following example specifies that HomePage objects should never be tested during update checks. For more information, see UpdateCheck.

[Column(Storage="_HomePage", DbType="NText", UpdateCheck=UpdateCheck.Never)]
public string HomePage
{
    get
    {
        return this._HomePage;
    }
    set
    {
        if ((this._HomePage != value))
	{
 	    this.OnHomePageChanging(value);
	    this.SendPropertyChanging();
            this._HomePage = value;
	    this.SendPropertyChanged("HomePage");
            this.OnHomePageChanged();
	}
    }
}
Show:
© 2014 Microsoft