SQL Server Timestamps and ADO.NET Concurrency


Url: http://msdn2.microsoft.com/en-US/library/system...

I was talking with a bright guy inside the ADO.NET team today when he told me that the DbCommandBuilder supports a new option called ConflictOption. This option alerts the DbCommandBuilder to use one of three methods for detecting concurrency conflicts:

  • CompareAllSearchableValues: The 1.x behavior of comparing all values to make sure the row hasn't changed. 
  • CompareRowVersion: This compares the primary key and a timestamp field (or rowversion).  This only works if the table has both a primary key and a timestamp (or rowversion) defined.
  • OverwriteChanges: This only compares the primary key and does not provide any concurrency, but simply allows for overriting of data.  *I DO NOT SUGGEST YOU USE THIS*.

Unfortunately, the TableAdapters in Typed DataSets (v 2.0) don't seem to be using this when they create their concurrency (the TableAdatper code generator uses a DbCommandBuilder to create the Update/Delete statements).

Additionally, the ASP.NET 2.0 DataSources do not use DbCommandBuilders so they won't use timestamps to do currency at all.  But my rant about DataSources is for another day.



Shawn
Shawn Wildermuth
Author, Teacher, and Coach




My Courses

Wilder Minds Training
Vue.js by Example (New Lower Price)
Bootstrap 4 by Example (New Lower Price)
Intro to Font Awesome 5 (Free Course)
Pluralsight
Building an API with ASP.NET Core (New Course)
Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.2)
Less: Getting Started (New)
Using Visual Studio Code for ASP.NET Core Projects
Implementing ASP.NET Web API

Application Name WilderBlog Environment Name Production
Application Ver v4.0.30319 Runtime Framework x86
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.27514.02
Operating System Microsoft Windows 10.0.14393 Runtime Arch X86