Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 697
Tim Avatar asked Nov 04 '22 02:11

Tim


1 Answers

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

like image 103
Atilla Ozgur Avatar answered Dec 18 '22 20:12

Atilla Ozgur