.NET System.Data namespace decompilation: where can I find the code relating to SQL Server concurrency violations

StackOverflow https://stackoverflow.com/questions/9946789

  •  28-05-2021
  •  | 
  •  

Вопрос

Where in the .NET System.Data namespace is the code that determines, when the update-command is executed, whether a row in a SQL Server 2K table has been changed after the client program had read it in, i.e. that the client-side version of the row is "stale"?

I would like to use a decompiler to look at the code and figure out how it determines that a concurrency violation has happened. I know it will have something to do with a timestamp column in the table and/or @@rowcount but I'd like to see just what is going on when an update command wrapped in a stored proc is executed by the library.

The stored proc would have this structure:

               create proc foo_update
                @id int,
                @rowversion timestamp,
                @val varchar(5)
                as
                 begin
                   update foo set a = @val
                   where id = @id and mytimestampcolumn = @rowversion; 
                 end

That is, no row will be updated if it has changed because of the where-clause which compares the rowversion in the client-side System.Data.DataRow to the timestamp value of the row in the database, and the proc would run successfully and not generate an error. Yet the SqlClient libraries, in their helpfulness, report this scenario as a concurrency violation.

Thanks

Это было полезно?

Решение 2

I found the relevant code in System.Data.Common.DbDataAdapter.cs -- the concurrency violation is raised when the number of affected records is zero.

Другие советы

Instead of using decompiler, look to real code. see following blog post for details. http://weblogs.asp.net/scottgu/archive/2008/01/16/net-framework-library-source-code-now-available.aspx

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top