Skip to content

Commit

Permalink
Working with Distributed Transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahi committed Oct 8, 2022
1 parent c3aafc8 commit dcea18f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
10 changes: 10 additions & 0 deletions daab/a00949.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
</li>
<li class="level3"><a href="#autotoc_md17">Managing Connections</a></li>
<li class="level3"><a href="#autotoc_md18">Working with Connection-Based Transactions</a></li>
<li class="level3"><a href="#autotoc_md19">Working with Distributed Transactions</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -563,6 +564,15 @@ <h4><a class="anchor" id="autotoc_md15"></a>
<div class="line"> trans.Rollback(); <span class="comment">// rollback the transaction</span></div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md19"></a>
Working with Distributed Transactions</h3>
<p>If you need to access different databases as part of the same transaction (including databases on separate servers), of if you need to include other data sources such as Microsoft Message Queuing (MSMQ) in your transaction, you must use a distributed transaction coordinator (DTC) mechanism such as Windows Component Services.</p>
<p>However, ADO.NET supports the concept of automatic transactions through the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.transactions.transactionscope">TransactionScope</a> class. You can specify that a series of actions require transactional support, but ADO.NET will not generate an expensive distributed transaction until you actually open more than one connection within the transaction scope. This means that you can perform multiple transacted updates to different tables in the same database over a single connection. As soon as you open a new connection, ADO.NET automatically creates a distributed transaction (using Windows Component Services), and enrolls the original connections and all new connections created within the transaction scope into that distributed transaction. You then call methods on the transaction scope to either commit all updates, or to roll back (undo) all of them.</p>
<p>This is done by the underlying ADO.NET. DAAB has no direct interaction with the DTC mechanism.</p>
<p>Typically, you will use the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.transactions.transactionscope">TransactionScope</a> class in the following way: </p><div class="fragment"><div class="line"><span class="keyword">using</span> (TransactionScope scope = <span class="keyword">new</span> TransactionScope(TransactionScopeOption.RequiresNew))</div>
<div class="line">{</div>
<div class="line"> <span class="comment">// perform data access here</span></div>
<div class="line">}</div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
Expand Down
2 changes: 1 addition & 1 deletion daab/a00950.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_Pages_ReleaseNotes"></a></p>
<h1><a class="anchor" id="autotoc_md19"></a>
<h1><a class="anchor" id="autotoc_md20"></a>
Version 7.0 RC1</h1>
<ul>
<li>The block was split to several NuGet packages, one for each database provider. See <a class="el" href="a00951.html">Upgrade</a> and <a class="el" href="a00949.html">User Guide</a> for details.</li>
Expand Down
3 changes: 2 additions & 1 deletion daab/annotated_dup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var annotated_dup =
[ "Updating the Database from a DataSet", "a00949.html#autotoc_md16", null ]
] ],
[ "Managing Connections", "a00949.html#autotoc_md17", null ],
[ "Working with Connection-Based Transactions", "a00949.html#autotoc_md18", null ]
[ "Working with Connection-Based Transactions", "a00949.html#autotoc_md18", null ],
[ "Working with Distributed Transactions", "a00949.html#autotoc_md19", null ]
] ],
[ "Microsoft", "a00242.html", [
[ "Practices", "a00243.html", [
Expand Down
4 changes: 2 additions & 2 deletions daab/navtreedata.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var NAVTREE =
[ "Data Access Application Block Documentation", "index.html", null ],
[ "Data Access Application Block User Guide", "a00949.html", null ],
[ "Data Access Application Block Release Notes", "a00950.html", [
[ "Version 7.0 RC1", "a00950.html#autotoc_md19", null ]
[ "Version 7.0 RC1", "a00950.html#autotoc_md20", null ]
] ],
[ "Upgrading from version 6 to version 7", "a00951.html", null ],
[ "Classes", "annotated.html", [
Expand All @@ -52,7 +52,7 @@ var NAVTREEINDEX =
"a00532.html#a9f8ee827a130d35f3cd1ae2b28eb0310",
"a00624.html#aec4e078b46f775b90d01038bab518c57",
"a00704.html#a27469f9c1ac7f0c4d1c86fdfc3000b0e",
"a00950.html#autotoc_md19"
"a00950.html"
];

var SYNCONMSG = 'click to disable panel synchronisation';
Expand Down
4 changes: 2 additions & 2 deletions daab/navtreeindex4.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ var NAVTREEINDEX4 =
"a00949.html#autotoc_md16":[3,10,1],
"a00949.html#autotoc_md17":[3,11],
"a00949.html#autotoc_md18":[3,12],
"a00949.html#autotoc_md19":[3,13],
"a00949.html#autotoc_md2":[2,0],
"a00949.html#autotoc_md3":[3],
"a00949.html#autotoc_md4":[3,0],
"a00949.html#autotoc_md5":[3,1],
"a00949.html#autotoc_md6":[3,2],
"a00949.html#autotoc_md7":[3,3],
"a00949.html#autotoc_md8":[3,4],
"a00949.html#autotoc_md9":[3,5],
"a00950.html":[2]
"a00949.html#autotoc_md9":[3,5]
};
9 changes: 5 additions & 4 deletions daab/navtreeindex5.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
var NAVTREEINDEX5 =
{
"a00950.html#autotoc_md19":[2,0],
"a00950.html":[2],
"a00950.html#autotoc_md20":[2,0],
"a00951.html":[3],
"annotated.html":[4,0],
"classes.html":[4,1],
"functions.html":[4,3,0],
"functions.html":[4,3,0,0],
"functions.html":[4,3,0],
"functions_b.html":[4,3,0,1],
"functions_c.html":[4,3,0,2],
"functions_d.html":[4,3,0,3],
"functions_e.html":[4,3,0,4],
"functions_f.html":[4,3,0,5],
"functions_func.html":[4,3,1,0],
"functions_func.html":[4,3,1],
"functions_func.html":[4,3,1,0],
"functions_func_b.html":[4,3,1,1],
"functions_func_c.html":[4,3,1,2],
"functions_func_d.html":[4,3,1,3],
Expand Down Expand Up @@ -45,7 +46,7 @@ var NAVTREEINDEX5 =
"functions_vars.html":[4,3,2],
"functions_w.html":[4,3,0,17],
"hierarchy.html":[4,2],
"index.html":[0],
"index.html":[],
"index.html":[0],
"pages.html":[]
};

0 comments on commit dcea18f

Please sign in to comment.