I’m learning transaction, I have no experience in using transaction in the real project. I know we can write transaction in ADO.NET, in Stored Procedure and in WCF. My confusion is where to write the transaction is more suitable? Do we need to write transaction in more than one place? If we write transaction in more than one place, does the performance will be affected?
Any one can lead me to the correct way?
Thx!
Here is a simple explanation.
For best performance, I write the transaction in the database (in a stored procedure) whenever possible. This is generally the simplest way to manage the transaction, and requires the least amount of code.
However, there are scenarios where that is not possible. For example, there may be updates to two different databases (or other kinds of data stores). In that situation, you would need to manage the transaction from within your application (using ADO.Net).
Similarly for WCF, if you are performing multiple tasks via a service, you may need to handle the transaction in the service if it cannot be handled in a database.