<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Updating Structured Objects</title> <link rel="stylesheet" type="text/css" href="../../../style.css"> </head> <body> <div class="CommonContent"> <div class="CommonContentArea"> <h1>Updating Structured Objects</h1><div id="TOC"><div id="TOCinner"><span class="TOCtitle">Contents</span><div class="TOCcontents"><ul><li><a href ="#Update Depth">Update Depth</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>To update structured objects in db4o, you simply call set() on them again.</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.cs: <span class="fscMemberName">UpdateCar</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61"><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;"> UpdateCar(IObjectContainer db) </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdateCar_142_61_53_273_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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</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 found </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"/> found.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;">"</span><span style="color: #800000;">Somebody else</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800080;">0</span><span style="color: #000000;">); </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(found); </span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> 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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</span><span style="color: #000000;">)); </span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> ListResult(result); </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> <p>[/filter] </p> <p><span name="cs_wiki_filter" csw_filters="vb"></p> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.vb: <span class="fscMemberName">UpdateCar</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub UpdateCar()</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdateCar_284_61_15_363_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> UpdateCar(</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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</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;"> found </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"/> found.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;">"</span><span style="color: #800000;">Somebody else</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800080;">0</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"/> db.Set(found) </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> 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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</span><span style="color: #000000;">)) </span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> ListResult(result) </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>Let's modify the pilot, too.</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.cs: <span class="fscMemberName">UpdatePilotSingleSession</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_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;"> UpdatePilotSingleSession(IObjectContainer db) </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSingleSession_452_76_68_269_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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</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 found </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"/> found.Pilot.AddPoints(</span><span style="color: #800080;">1</span><span style="color: #000000;">); </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(found); </span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> 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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</span><span style="color: #000000;">)); </span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> ListResult(result); </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> <p></span> </p> <p><span name="cs_wiki_filter" csw_filters="vb"></p> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.vb: <span class="fscMemberName">UpdatePilotSingleSession</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub UpdatePilotSingleSession()</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSingleSession_607_76_15_359_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> UpdatePilotSingleSession(</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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</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;"> found </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"/> found.Pilot.AddPoints(</span><span style="color: #800080;">1</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"/> db.Set(found) </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> 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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</span><span style="color: #000000;">)) </span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> ListResult(result) </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>Nice and easy, isn't it? But there is something that is not obvious in this example. Let's see what happens if we split this task in two separate db4o sessions: In the first we modify our pilot and update his car:</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.cs: <span class="fscMemberName">UpdatePilotSeparateSessionsPart1</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84"><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;"> UpdatePilotSeparateSessionsPart1(IObjectContainer db) </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsPart1_975_84_76_214_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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</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 found </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"/> found.Pilot.AddPoints(</span><span style="color: #800080;">1</span><span style="color: #000000;">); </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(found); </span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> }</span></span></div></pre></div></div> <p></span> </p> <p><span name="cs_wiki_filter" csw_filters="vb"></p> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.vb: <span class="fscMemberName">UpdatePilotSeparateSessionsPart1</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub UpdatePilotSeparateSessionsPart1()</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsPart1_1138_84_15_288_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> UpdatePilotSeparateSessionsPart1(</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;">"</span><span style="color: #800000;">Ferrari</span><span style="color: #800000;">"</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;"> found </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"/> found.Pilot.AddPoints(</span><span style="color: #800080;">1</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"/> db.Set(found) </span><span style="color: #008080;">6</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>And in the second, we'll double-check our modification:</p> <p>If you will execute this code you will see that Pilot's points are not changed What's happening here and what can we do to fix it?</p> <a name="Update Depth"></a><h2>Update Depth</h2> <p>Imagine a complex object with many members that have many members themselves. When updating this object, db4o would have to update all its children, grandchildren, etc. This poses a severe performance penalty and will not be necessary in most cases - sometimes, however, it will.<br><br>So, in our previous update example, we were modifying the Pilot child of a Car object. When we saved the change, we told db4o to save our Car object and assumed that the modified Pilot would be updated. But we were modifying and saving in the same manner as we were in the first update sample, so why did it work before? The first time we made the modification, db4o never actually had to retreive the modified Pilot it returned the same one that was still in memory that we modified, but it never actually updated the database. Restarting the application would show that the value was unchanged.<br><br>To be able to handle this dilemma as flexible as possible, db4o introduces the concept of update depth to control how deep an object's member tree will be traversed on update. The default update depth for all objects is 0, meaning that only primitive and String members will be updated, but changes in object members will not be reflected.<br><br>db4o provides means to control update depth with very fine granularity. For our current problem we'll advise db4o to update the full graph for Car objects by setting cascadeOnUpdate() for this class accordingly.<br><br>[filter=java]</p> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.java: <span class="fscMemberName">updatePilotSeparateSessionsImprovedPart1</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Open_Text').style.display='inline';"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> Configuration updatePilotSeparateSessionsImprovedPart1() </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredJava.ZipsStructuredExample.Java_StructuredExample.Java_UpdatePilotSeparateSessionsImprovedPart1_3035_96_72_241_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> Configuration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4o.newConfiguration(); </span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> configuration.objectClass(</span><span style="color: #000000;">"</span><span style="color: #000000;">com.db4o.f1.chapter2.Car</span><span style="color: #000000;">"</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"/> .cascadeOnUpdate(</span><span style="color: #0000FF;">true</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"/> </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> configuration; </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> }</span></span></div></pre></div></div> <p></span> </p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.cs: <span class="fscMemberName">UpdatePilotSeparateSessionsImprovedPart1</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92"><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;"> IConfiguration UpdatePilotSeparateSessionsImprovedPart1() </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredCS.ZipsStructuredExample.Cs_StructuredExample.Cs_UpdatePilotSeparateSessionsImprovedPart1_3208_92_75_263_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"/> IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration(); </span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> configuration.ObjectClass(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car)).CascadeOnUpdate(</span><span style="color: #0000FF;">true</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"/> </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> configuration; </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> }</span></span></div></pre></div></div> <p>[/filter] </p> <p><span name="cs_wiki_filter" csw_filters="vb"></p> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">StructuredExample.vb: <span class="fscMemberName">UpdatePilotSeparateSessionsImprovedPart1</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function UpdatePilotSeparateSessionsImprovedPart1()</span><span id="ResourcesReferenceObject_LifecycleWorking_With_Structured_ObjectsstructuredVB.ZipsStructuredExample.Vb_StructuredExample.Vb_UpdatePilotSeparateSessionsImprovedPart1_3381_92_15_321_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> UpdatePilotSeparateSessionsImprovedPart1(</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: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </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;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration() </span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> configuration.ObjectClass(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car)).CascadeOnUpdate(</span><span style="color: #0000FF;">True</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"/> </span><span style="color: #0000FF;">Return</span><span style="color: #000000;"> configuration </span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Function</span></span></div></pre></div></div> </span> <p>You can also achieve expected results using:</p> <ol> <li>ExtObjectContainer#set(object, depth) to update exact amount of referenced fields</li> <li>Use configuration.objectClass(clazz).updateDepth(depth) setting to define sufficient update depth for a specific object</li> <li>Use global setting for all the persisted objects:</li> </ol> <span name="cs_wiki_filter" csw_filters="cs"> <p>c#: <code>configuration.UpdateDepth(depth);</code></p> <p></span> </p> <p>[filter=vb]</p> <p>VB: <code>configuration.UpdateDepth(depth);</code></p> </span> <p>However global updateDepth is not flexible enough for real-world objects having different depth of reference structures. </p><p>ATTENTION: Setting global update depth to the maximum value will result in serious performance penalty. Please, use this setting ONLY for debug purposes.<br></p> <p>Note that container configuration must be set before the container is opened and/or passed to the <code>openFile/openClient/openServer</code> method.</p></div> </div> <div id="footer"> This revision (9) was last Modified 2007-04-23T06:59:02 by Tetyana. </div> </body> </html>