<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Updating List Objects</title> <link rel="stylesheet" type="text/css" href="../../../../style.css"> </head> <body> <div class="CommonContent"> <div class="CommonContentArea"> <h1>Updating List Objects</h1><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>As we discussed <a href="../collections_update_depth.html" class="wikiLink">before</a> updating list members using update depth is quite inefficient. An alternative approach can be retrieving and updating each object from the list separately:</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">ListOperationsExample.cs: <span class="fscMemberName">UpdateObject</span></span></div><div class="fscCode"><pre ID="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75"><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;"> UpdateObject() </span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Open_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Closed_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Closed_Text').style.display='inline';"/><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Closed_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Open_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Open_Text').style.display='inline';"/> </span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_43_1134_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"/> Stopwatch sw </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Stopwatch(); </span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(DbFile); </span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> </span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Open_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Closed_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Closed_Text').style.display='inline';"/><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Closed_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Open_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Open_Text').style.display='inline';"/> </span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_182_974_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008000;">//</span><span style="color: #008000;"> we can set update depth to 0 </span><span style="color: #008080;">09</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008000;">//</span><span style="color: #008000;"> as we update only the current object</span><span style="color: #008000;"> </span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> db.Ext().Configure().UpdateDepth(</span><span style="color: #800080;">0</span><span style="color: #000000;">); </span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> IList</span><span style="color: #000000;"><</span><span style="color: #000000;">ListObject</span><span style="color: #000000;">></span><span style="color: #000000;"> result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query</span><span style="color: #000000;"><</span><span style="color: #000000;">ListObject</span><span style="color: #000000;">></span><span style="color: #000000;">(); </span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (result.Count </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">) </span><span style="color: #008080;">13</span><span style="color: #000000;"><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Open_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Closed_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Closed_Text').style.display='inline';"/><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Closed_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Open_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Open_Text').style.display='inline';"/> </span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_464_960_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> ListObject lo1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> result[</span><span style="color: #800080;">0</span><span style="color: #000000;">]; </span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> DataObject dataobject </span><span style="color: #000000;">=</span><span style="color: #000000;"> lo1.Data[</span><span style="color: #800080;">0</span><span style="color: #000000;">]; </span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> dataobject.Name </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Updated</span><span style="color: #800000;">"</span><span style="color: #000000;">; </span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> dataobject.Data </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.Now.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;"> ---- Updated Object </span><span style="color: #800000;">"</span><span style="color: #000000;">; </span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">Updated list {0} dataobject {1}</span><span style="color: #800000;">"</span><span style="color: #000000;">, lo1.Name, lo1.Data[</span><span style="color: #800080;">0</span><span style="color: #000000;">]); </span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> sw.Start(); </span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(dataobject); </span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Commit(); </span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> sw.Stop(); </span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> }</span></span><span style="color: #000000;"> </span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> }</span></span><span style="color: #000000;"> </span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> </span><span style="color: #008080;">27</span><span style="color: #000000;"><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Open_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Closed_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Closed_Text').style.display='inline';"/><img id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Closed_Text').style.display='none'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Open_Image').style.display='inline'; document.getElementById('..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Open_Text').style.display='inline';"/> </span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="..ListOperationsCS.ZipsListOperationsExample.Cs_ListOperationsExample.Cs_UpdateObject_283_75_1007_1050_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">28</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Close(); </span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> }</span></span><span style="color: #000000;"> </span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">Storing took {0}</span><span style="color: #800000;">"</span><span style="color: #000000;">, sw.Elapsed.ToString()); </span><span style="color: #008080;">31</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">ListOperationsExample.vb: <span class="fscMemberName">UpdateObject</span></span></div><div class="fscCode"><pre ID="..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">01</span><img id="..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Open_Text').style.display='none'; document.getElementById('..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Closed_Image').style.display='inline'; document.getElementById('..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Closed_Text').style.display='inline';"/><img id="..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Closed_Text').style.display='none'; document.getElementById('..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Open_Image').style.display='inline'; document.getElementById('..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_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="..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub UpdateObject()</span><span id="..ListOperationsVB.ZipsListOperationsExample.Vb_ListOperationsExample.Vb_UpdateObject_422_75_15_1094_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> UpdateObject() </span><span style="color: #008080;">02</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;"> sw </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Stopwatch </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Stopwatch </span><span style="color: #008080;">03</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;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(DbFile) </span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;"> </span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008000;">'</span><span style="color: #008000;"> we can set update depth to 0 </span><span style="color: #008000;"> </span><span style="color: #008080;">06</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #008000;">'</span><span style="color: #008000;"> as we update only the current object</span><span style="color: #008000;"> </span><span style="color: #008080;">07</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> db.Ext.Configure.UpdateDepth(</span><span style="color: #800080;">0</span><span style="color: #000000;">) </span><span style="color: #008080;">08</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;"> IList(</span><span style="color: #0000FF;">Of</span><span style="color: #000000;"> ListObject) </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query(</span><span style="color: #0000FF;">Of</span><span style="color: #000000;"> ListObject)() </span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> result.Count </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</span><span style="color: #000000;"> </span><span style="color: #008080;">10</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;"> lo1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> ListObject </span><span style="color: #000000;">=</span><span style="color: #000000;"> result(</span><span style="color: #800080;">0</span><span style="color: #000000;">) </span><span style="color: #008080;">11</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;"> dataobject </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DataObject </span><span style="color: #000000;">=</span><span style="color: #000000;"> lo1.Data(</span><span style="color: #800080;">0</span><span style="color: #000000;">) </span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> dataobject.Name </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Updated</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> dataobject.Data </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.Now.ToString </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;"> ---- Updated Object </span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">Updated list {0} dataobject {1}</span><span style="color: #800000;">"</span><span style="color: #000000;">, lo1.Name, lo1.Data(</span><span style="color: #800080;">0</span><span style="color: #000000;">)) </span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> sw.Start() </span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(dataobject) </span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Commit() </span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> sw.Stop() </span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> </span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;"> </span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Close() </span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;"> </span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">Storing took {0}</span><span style="color: #800000;">"</span><span style="color: #000000;">, sw.Elapsed.ToString) </span><span style="color: #008080;">24</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> In this case only the object of interest is updated, which takes much less time than updating the whole list. </div> </div> <div id="footer"> This revision (4) was last Modified 2007-06-15T15:55:34 by Tetyana. </div> </body> </html>