Edit

Share via


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

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 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


Additional resources

Training

Module

Understand concurrency in PostgreSQL - Training

Azure Database for PostgreSQL is a multi-user relational database solution. The ability to support many concurrent users enables PostgreSQL databases to scale out and enable applications that support many users and locations at the same time. The increase in users brings a risk of conflicts. For this reason, it's important to understand the concurrency systems that are in place in Azure Database for PostgreSQL to manage concurrency and conflicts. In this module, we look at both isolation levels and locking