ChangeConflictException in Linq to Sql update

后端 未结 4 631
感动是毒
感动是毒 2020-12-14 19:57

I\'m in a world of pain with this one, and I\'d very much appreciate it if someone could help out.

I have a DataContext attached to a single test table on a database

4条回答
  •  北海茫月
    2020-12-14 20:25

    I finally figured out what was happening with this. Apparently, the "no count" option was turned on for this server.

    In Microsoft SQL Server Management Studio 2005:

    1. Right click on the server and click Properties
    2. On the left hand of the Server Properties window, select the Connections page
    3. Under Default connection options, ensure that "no count" is not selected.

    Apparently, LINQ to SQL uses @@ROWCOUNT after updates to issue an automated optimistic concurrency check. Of course, if "no count" is turned on for the entire server, @@ROWCOUNT always returns zero, and LINQ to SQL throws a ConcurrencyException after issuing updates to the database.

    This isn't the only update behavior LINQ to SQL uses. LINQ to SQL doesn't perform an automated optimistic concurrency check with @@ROWCOUNT if you have a TIMESTAMP column on your table.

提交回复
热议问题