What is the best approach for managing concurrency problems in C# .NET database applications? Any rules of thumb I should know about?
Generally, if you're going to perform operations on multiple databases/servers, you must use Enterprise Services (i.e., your classes inheriting from ServicedComponent). If you're working against a single database, try using manual transactions, or some approach like the one in CodeProject, and using optimistic concurrency whenever you can. The traditional way of doing this is retrieving timestamps for the rows you're using, and then comparing these timestamps with the current ones on the database. If they don't match, someone else's modified it, and you usually show the user both the actual values and his proposed changes, and let him chose which ones should prevail.
Dig Deeper on C# programming language
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading