How to: Specify Which Members are Tested for Concurrency Conflicts (LINQ to SQL)

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 (LINQ to SQL).

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.

Example

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 Property HomePage() As String 
    Get 
        Return Me._HomePage
    End Get 
    Set(ByVal value As String)
        If ((Me._HomePage <> value)  _
            = false) Then 
        Me.OnHomePageChanging(value)
            Me.SendPropertyChanging
            Me._HomePage = value
            Me.SendPropertyChanged("HomePage")
            Me.OnHomePageChanged
        End If 
    End Set 
End Property
[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();
    }
    }
}

See Also

Other Resources

How to: Manage Change Conflicts (LINQ to SQL)

Making and Submitting Data Changes (LINQ to SQL)