Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 177

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Transaction</title>
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Transaction</h1><div id="TOC"><div id="TOCinner"><span class="TOCtitle">Contents</span><div class="TOCcontents"><ul><li><a href ="#Commit And Rollback">Commit And Rollback</a></li><li><a href ="#Refresh Live Objects">Refresh Live Objects</a></li></ul></li></ul></div></div></div><script>
//We attach this function to a browser object as a variable so that if multiple of these blocks are
//present on the same page, then they will simply over-write eachother with the same function instead
//of generating a naming collision.
window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){
	var sContent = document.getElementById(sID).innerText;
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", sContent);
	}
	else
	{
		alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions.");
	}
}
</script>


<p>All work within db4o ObjectContainer is transactional. A transaction is implicitly started when you open a container, and the current transaction is implicitly committed when you close it again. db4o transaction is tied to&nbsp; an open object container and only one transaction is allowed per object container instance.<br></p>
<a name="Commit And Rollback"></a><h2>Commit And Rollback</h2>
<p>You may choose to make a commit explicit or you may leave it for the <code>#close()</code> call:</p>



<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.cs: <span class="fscMemberName">StoreCarCommit</span></span></div><div class="fscCode"><pre ID=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> StoreCarCommit(IObjectContainer db)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Open_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Closed_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Closed_Text').style.display='inline';"/><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Closed_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Open_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Open_Text').style.display='inline';"/>        </span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarCommit_529_71_64_257_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Pilot pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Rubens Barrichello</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">99</span><span style="color: #000000;">);
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Car car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> pilot;
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car);
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Commit();
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.cs: <span class="fscMemberName">ListAllCars</span></span></div><div class="fscCode"><pre ID=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> ListAllCars(IObjectContainer db)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Open_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Closed_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Closed_Text').style.display='inline';"/><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Closed_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Open_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Open_Text').style.display='inline';"/>        </span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_602_68_61_157_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            ListResult(result);
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.vb: <span class="fscMemberName">StoreCarCommit</span></span></div><div class="fscCode"><pre ID=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Open_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Closed_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Closed_Text').style.display='inline';"/><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Closed_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Open_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub StoreCarCommit()</span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarCommit_734_67_14_269_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> StoreCarCommit(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Rubens Barrichello</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">99</span><span style="color: #000000;">)
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> pilot
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car)
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Commit()
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div><br><div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.vb: <span class="fscMemberName">ListAllCars</span></span></div><div class="fscCode"><pre ID=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Open_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Closed_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Closed_Text').style.display='inline';"/><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Closed_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Open_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub ListAllCars()</span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_805_65_14_166_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> ListAllCars(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            ListResult(result)
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>Before transaction is commited all the modifications to a database are written to a temporary memory storage. Commit (explicit or implicit) writes the modifications to the disk.</p>

<p>Please, remember to always commit or close your ObjectContainer when the work is done, to make sure that the data is saved to the permanent storage. <a href="../tuning/performance_hints/commit_strategies.html" class="wikiLink">Commit Strategies</a> contains some important information on when and how commit should be used to achieve the best performance.<br></p>

<p>If you do not want to save changes to the database, you can call rollback, resetting the&nbsp;state of our database to the last commit point.</p>



<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.cs: <span class="fscMemberName">StoreCarRollback</span></span></div><div class="fscCode"><pre ID=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> StoreCarRollback(IObjectContainer db)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Open_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Closed_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Closed_Text').style.display='inline';"/><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Closed_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Open_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Open_Text').style.display='inline';"/>        </span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_StoreCarRollback_1601_69_66_266_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Pilot pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">100</span><span style="color: #000000;">);
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Car car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> pilot;
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car);
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Rollback();
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div><br><div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.cs: <span class="fscMemberName">ListAllCars</span></span></div><div class="fscCode"><pre ID=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> ListAllCars(IObjectContainer db)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Open_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Closed_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Closed_Text').style.display='inline';"/><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Closed_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Open_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Open_Text').style.display='inline';"/>        </span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_ListAllCars_1674_65_61_157_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            ListResult(result);
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.vb: <span class="fscMemberName">StoreCarRollback</span></span></div><div class="fscCode"><pre ID=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Open_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Closed_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Closed_Text').style.display='inline';"/><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Closed_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Open_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub StoreCarRollback()</span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_StoreCarRollback_1803_69_14_278_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> StoreCarRollback(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">100</span><span style="color: #000000;">)
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> pilot
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car)
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Rollback()
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div><br><div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.vb: <span class="fscMemberName">ListAllCars</span></span></div><div class="fscCode"><pre ID=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Open_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Closed_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Closed_Text').style.display='inline';"/><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Closed_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Open_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub ListAllCars()</span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_ListAllCars_1876_65_14_166_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> ListAllCars(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            ListResult(result)
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>
<a name="Refresh Live Objects"></a><h2>Refresh Live Objects</h2>
<p>There is one thing that you should remember when rolling back: the <code>#rollback()</code> method will cancel the modifications, but it won't change back the state of the objects in your reference cache.</p>



<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.cs: <span class="fscMemberName">CarSnapshotRollback</span></span></div><div class="fscCode"><pre ID=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> CarSnapshotRollback(IObjectContainer db)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Open_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Closed_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Closed_Text').style.display='inline';"/><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Closed_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Open_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Open_Text').style.display='inline';"/>        </span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollback_2253_76_69_294_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">));
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Car car </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Car)result.Next();
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Snapshot();
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car);
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Rollback();
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Console.WriteLine(car);
</span><span style="color: #008080;">9</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.vb: <span class="fscMemberName">CarSnapshotRollback</span></span></div><div class="fscCode"><pre ID=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Open_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Closed_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Closed_Text').style.display='inline';"/><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Closed_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Open_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub CarSnapshotRollback()</span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollback_2393_76_14_317_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> CarSnapshotRollback(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">))
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">DirectCast</span><span style="color: #000000;">(result.Next(), Car)
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Snapshot()
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car)
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Rollback()
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Console.WriteLine(car)
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>You have to explicitly refresh your live objects when their state might become different from the state in the database:</p>



<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.cs: <span class="fscMemberName">CarSnapshotRollbackRefresh</span></span></div><div class="fscCode"><pre ID=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> CarSnapshotRollbackRefresh(IObjectContainer db)
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Open_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Closed_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Closed_Text').style.display='inline';"/><img id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Closed_Text').style.display='none'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Open_Image').style.display='inline'; document.getElementById('.TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Open_Text').style.display='inline';"/>        </span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".TransactionsCS.ZipsTransactionExample.Cs_TransactionExample.Cs_CarSnapshotRollbackRefresh_2668_83_76_346_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectSet result</span><span style="color: #000000;">=</span><span style="color: #000000;">db.Get(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">));
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Car car</span><span style="color: #000000;">=</span><span style="color: #000000;">(Car)result.Next();
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Snapshot();
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car);
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Rollback();
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Ext().Refresh(car, </span><span style="color: #0000FF;">int</span><span style="color: #000000;">.MaxValue);
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Console.WriteLine(car);
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TransactionExample.vb: <span class="fscMemberName">CarSnapshotRollbackRefresh</span></span></div><div class="fscCode"><pre ID=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Open_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Closed_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Closed_Text').style.display='inline';"/><img id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Closed_Text').style.display='none'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Open_Image').style.display='inline'; document.getElementById('.TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub CarSnapshotRollbackRefresh()</span><span id=".TransactionsVB.ZipsTransactionExample.Vb_TransactionExample.Vb_CarSnapshotRollbackRefresh_2815_83_14_376_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> CarSnapshotRollbackRefresh(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">))
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">DirectCast</span><span style="color: #000000;">(result.Next(), Car)
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Snapshot()
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car)
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Rollback()
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Ext().Refresh(car, </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;">.MaxValue)
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Console.WriteLine(car)
</span><span style="color: #008080;">9</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>The <code>#refresh()</code> method might be also helpful when the changes to the database are done&nbsp;from different threads. See <a href="../client-server.html" class="wikiLink">Client-Server</a> for more information.</p></div>
    </div>
    <div id="footer">
					This revision (13) was last Modified 2007-08-20T12:18:37 by Tetyana.
				</div>
  </body>
</html>