<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Autoincrement</title> <link rel="stylesheet" type="text/css" href="../../../../style.css"> </head> <body> <div class="CommonContent"> <div class="CommonContentArea"> <h1>Autoincrement</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>Db4o does not deliver a field autoincrement feature, which is common in RDBMS. If your application logic requires this feature you can implement it using External Callbacks. One of the possible solutions is presented below.</p> <p>We will need an object to store the last generated ID and to return a new ID on request:</p> <span name="cs_wiki_filter" csw_filters="cs"><div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IncrementedId.cs</span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">01</span><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Open_Text').style.display='inline';"/><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_0_67_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> Copyright (C) 2004 - 2006 db4objects Inc. </span><span style="color: #008000; text-decoration: underline;">http://www.db4o.com</span><span style="color: #008000;"> </span><span style="color: #008000;">*/</span></span><span style="color: #000000;"> </span><span style="color: #008080;">02</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Open_Text').style.display='inline';"/></span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_68_178_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> </span><span style="color: #008080;">03</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> * Singleton class used to keep auotincrement information </span><span style="color: #008080;">04</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> * and give the next available ID on request </span><span style="color: #008080;">05</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> </span><span style="color: #008000;">*/</span></span><span style="color: #000000;"> </span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">using</span><span style="color: #000000;"> System; </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">using</span><span style="color: #000000;"> Db4objects.Db4o; </span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/> </span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Callbacks </span><span style="color: #008080;">10</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Open_Text').style.display='inline';"/></span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_256_1387_Open_Text"><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;">class</span><span style="color: #000000;"> IncrementedId </span><span style="color: #008080;">12</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_286_1385_Open_Text"><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"/> </span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> _no; </span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> IncrementedId _ref; </span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">private</span><span style="color: #000000;"> IncrementedId() </span><span style="color: #008080;">17</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_397_429_Open_Text"><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"/> _no </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">; </span><span style="color: #008080;">19</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;">20</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;"> end IncrementedId</span><span style="color: #008000;"> </span><span style="color: #008080;">21</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </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;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> GetNextID(IObjectContainer db) </span><span style="color: #008080;">23</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_518_598_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _no</span><span style="color: #000000;">++</span><span style="color: #000000;">; </span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(</span><span style="color: #0000FF;">this</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;">return</span><span style="color: #000000;"> _no; </span><span style="color: #008080;">27</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;">28</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;"> end increment</span><span style="color: #008000;"> </span><span style="color: #008080;">29</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></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"/> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> IncrementedId GetIdObject(IObjectContainer db) </span><span style="color: #008080;">31</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_702_1352_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">32</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;"> if _ref is not assigned yet:</span><span style="color: #008000;"> </span><span style="color: #008080;">33</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (_ref </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">) </span><span style="color: #008080;">34</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_790_1073_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">35</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;"> check if there is a stored instance from the previous </span><span style="color: #008080;">36</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;"> session in the database</span><span style="color: #008000;"> </span><span style="color: #008080;">37</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> IObjectSet os </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(IncrementedId)); </span><span style="color: #008080;">38</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;"> (os.Size() </span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">) </span><span style="color: #008080;">39</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _ref </span><span style="color: #000000;">=</span><span style="color: #000000;"> (IncrementedId)os.Next(); </span><span style="color: #008080;">40</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;">41</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">42</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;"> (_ref </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">) </span><span style="color: #008080;">43</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsIncrementedId.Cs_IncrementedId.Cs_386_46_1117_1317_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">44</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;"> create new instance and store it</span><span style="color: #008000;"> </span><span style="color: #008080;">45</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">Id object is created</span><span style="color: #800000;">"</span><span style="color: #000000;">); </span><span style="color: #008080;">46</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _ref </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> IncrementedId(); </span><span style="color: #008080;">47</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(_ref); </span><span style="color: #008080;">48</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;">49</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;"> _ref; </span><span style="color: #008080;">50</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;">51</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;"> end getIdObject</span><span style="color: #008000;"> </span><span style="color: #008080;">52</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/></span><span style="color: #000000;"> }</span></span><span style="color: #000000;"> </span><span style="color: #008080;">53</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">IncrementedId.vb</span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46"><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: #008000;">'</span><span style="color: #008000;"> Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */</span><span style="color: #008000;"> </span><span style="color: #008080;">02</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #008000;">'</span><span style="color: #008000;"> Singleton class used to keep auotincrement information </span><span style="color: #008000;"> </span><span style="color: #008080;">04</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/>'</span><span style="color: #008000;"> and give the next available ID on request</span><span style="color: #008000;"> </span><span style="color: #008080;">05</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">Imports</span><span style="color: #000000;"> System </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">Imports</span><span style="color: #000000;"> Db4objects.Db4o </span><span style="color: #008080;">08</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Open_Text').style.display='inline';"/></span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Namespace Db4objects</span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_210_1503_Open_Text"><span style="color: #0000FF;">Namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Callbacks </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: #008080;">10</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Open_Text').style.display='inline';"/> </span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Class IncrementedId</span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_254_1489_Open_Text"><span style="color: #0000FF;">Class</span><span style="color: #000000;"> IncrementedId </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;">Private</span><span style="color: #000000;"> _no </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</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;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> _ref </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IncrementedId </span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">14</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub New()</span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_367_412_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</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"/> _no </span><span style="color: #000000;">=</span><span style="color: #000000;"> </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/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Sub</span></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"/> </span><span style="color: #008000;">'</span><span style="color: #008000;"> end New</span><span style="color: #008000;"> </span><span style="color: #008080;">18</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #008080;">19</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function GetNextID()</span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_447_655_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> GetNextID(</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;"> </span><span style="color: #0000FF;">Integer</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"/> System.Math.Min(System.Threading.Interlocked.Increment(_no), _no </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</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.Set(</span><span style="color: #0000FF;">Me</span><span style="color: #000000;">) </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;">Return</span><span style="color: #000000;"> _no </span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Function</span></span><span style="color: #000000;"> </span><span style="color: #008080;">24</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;"> end GetNextID</span><span style="color: #008000;"> </span><span style="color: #008080;">25</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #008080;">26</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function GetIdObject()</span><span id=".AutoIncVB.ZipsIncrementedId.Vb_IncrementedId.Vb_486_46_703_1448_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> GetIdObject(</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;"> IncrementedId </span><span style="color: #008080;">27</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;"> if _ref is not assigned yet:</span><span style="color: #008000;"> </span><span style="color: #008080;">28</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> _ref </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Nothing</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</span><span style="color: #000000;"> </span><span style="color: #008080;">29</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;"> check if there is a stored instance from the previous </span><span style="color: #008000;"> </span><span style="color: #008080;">30</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;"> session in the database</span><span style="color: #008000;"> </span><span style="color: #008080;">31</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> os </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;">(IncrementedId)) </span><span style="color: #008080;">32</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;"> os.Size </span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</span><span style="color: #000000;"> </span><span style="color: #008080;">33</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _ref </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(os.Next, IncrementedId) </span><span style="color: #008080;">34</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;">35</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;">36</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;"> _ref </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Nothing</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</span><span style="color: #000000;"> </span><span style="color: #008080;">37</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;"> create new instance and store it</span><span style="color: #008000;"> </span><span style="color: #008080;">38</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">Id object is created</span><span style="color: #800000;">"</span><span style="color: #000000;">) </span><span style="color: #008080;">39</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _ref </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> IncrementedId </span><span style="color: #008080;">40</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(_ref) </span><span style="color: #008080;">41</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;">42</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;"> _ref </span><span style="color: #008080;">43</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Function</span></span><span style="color: #000000;"> </span><span style="color: #008080;">44</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;"> end GetIdObject</span><span style="color: #008000;"> </span><span style="color: #008080;">45</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #008080;">46</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Class</span></span><span style="color: #000000;"> </span><span style="color: #008080;">47</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/></span><span style="color: #0000FF;">End Namespace</span></span></div></pre></div></div> </span> <p>This object generates the simplest ID, which is an autoincremented integer value. You can add your own algorithm to generate more sophisticated ID sequences, like ABC0001DEF.</p> <p>When you use external callbacks you are not limited to a single object: a callback can apply to any group of objects Thus you can create a sequence of classes sharing the same autoincrement. To distinguish the objects, which will have an autoincremented field, we will use an abstract (MustInherit in VB) class:</p><span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CountedObject.cs</span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">01</span><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Open_Text').style.display='inline';"/><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_0_67_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> Copyright (C) 2004 - 2006 db4objects Inc. </span><span style="color: #008000; text-decoration: underline;">http://www.db4o.com</span><span style="color: #008000;"> </span><span style="color: #008000;">*/</span></span><span style="color: #000000;"> </span><span style="color: #008080;">02</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Open_Text').style.display='inline';"/></span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_68_151_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> </span><span style="color: #008080;">03</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> * This class is used to mark classes that need to get an autoincremented ID </span><span style="color: #008080;">04</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> </span><span style="color: #008000;">*/</span></span><span style="color: #000000;"> </span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Callbacks </span><span style="color: #008080;">06</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Open_Text').style.display='inline';"/></span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_191_454_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">abstract</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> CountedObject </span><span style="color: #008080;">08</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_230_452_Open_Text"><span style="color: #000000;">{ </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;">protected</span><span style="color: #000000;"> </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> _id; </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: #008080;">11</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> Id </span><span style="color: #008080;">12</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_290_446_Open_Text"><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"/> </span><span style="color: #0000FF;">get</span><span style="color: #000000;"> </span><span style="color: #008080;">14</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_320_363_Open_Text"><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"/> </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> _id; </span><span style="color: #008080;">16</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;">17</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">set</span><span style="color: #000000;"> </span><span style="color: #008080;">18</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsCountedObject.Cs_CountedObject.Cs_1101_46_392_436_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _id </span><span style="color: #000000;">=</span><span style="color: #000000;"> value; </span><span style="color: #008080;">20</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;">21</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;">22</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;">23</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">CountedObject.vb</span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46"><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: #008000;">'</span><span style="color: #008000;"> Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */</span><span style="color: #008000;"> </span><span style="color: #008080;">02</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/>'</span><span style="color: #008000;">This class is used to mark classes that need to get an autoincremented ID</span><span style="color: #008000;"> </span><span style="color: #008080;">03</span><span style="color: #008000;"><img id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Open_Text').style.display='inline';"/></span><span id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Namespace Db4objects</span><span id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_142_491_Open_Text"><span style="color: #0000FF;">Namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Callbacks </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 id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">MustInherit</span><span style="color: #000000;"> </span><span id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Class CountedObject</span><span id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_198_477_Open_Text"><span style="color: #0000FF;">Class</span><span style="color: #000000;"> CountedObject </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;">Protected</span><span style="color: #000000;"> _id </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;"> </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">08</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Property Id()</span><span id=".AutoIncVB.ZipsCountedObject.Vb_CountedObject.Vb_1209_46_267_463_Open_Text"><span style="color: #0000FF;">Property</span><span style="color: #000000;"> Id() </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;"> </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;">Get</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;">Return</span><span style="color: #000000;"> _id </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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Get</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;">Set</span><span style="color: #000000;">(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> value </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</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"/> _id </span><span style="color: #000000;">=</span><span style="color: #000000;"> value </span><span style="color: #008080;">14</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;">Set</span><span style="color: #000000;"> </span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Property</span></span><span style="color: #000000;"> </span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Class</span></span><span style="color: #000000;"> </span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/></span><span style="color: #0000FF;">End Namespace</span></span></div></pre></div></div> </span> <p>Each object extending CountedObject will get an autoincremented ID. For example:</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">TestObject.cs</span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">01</span><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Open_Text').style.display='inline';"/><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_0_67_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> Copyright (C) 2004 - 2006 db4objects Inc. </span><span style="color: #008000; text-decoration: underline;">http://www.db4o.com</span><span style="color: #008000;"> </span><span style="color: #008000;">*/</span></span><span style="color: #000000;"> </span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Callbacks </span><span style="color: #008080;">03</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Open_Text').style.display='inline';"/></span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_107_330_Open_Text"><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"/> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> TestObject: CountedObject </span><span style="color: #008080;">05</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_149_328_Open_Text"><span style="color: #000000;">{ </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;">string</span><span style="color: #000000;"> _name; </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">08</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> TestObject(</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> name) </span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_212_240_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _name </span><span style="color: #000000;">=</span><span style="color: #000000;"> name; </span><span style="color: #008080;">10</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;">11</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">12</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">override</span><span style="color: #000000;"> </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> ToString() </span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsTestObject.Cs_TestObject.Cs_1413_43_286_322_Open_Text"><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"/> </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> _name</span><span style="color: #000000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">/</span><span style="color: #800000;">"</span><span style="color: #000000;">+</span><span style="color: #000000;">_id; </span><span style="color: #008080;">14</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;">15</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;">16</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">TestObject.vb</span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43"><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: #008000;">'</span><span style="color: #008000;"> Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com </span><span style="color: #008000;"> </span><span style="color: #008080;">02</span><span style="color: #008000;"><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Open_Text').style.display='inline';"/></span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Namespace Db4objects</span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_65_438_Open_Text"><span style="color: #0000FF;">Namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Callbacks </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: #008080;">04</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Open_Text').style.display='inline';"/> </span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Class TestObject</span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_109_424_Open_Text"><span style="color: #0000FF;">Class</span><span style="color: #000000;"> TestObject </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: #0000FF;">Inherits</span><span style="color: #000000;"> CountedObject </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;">Private</span><span style="color: #000000;"> _name </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">String</span><span style="color: #000000;"> </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008080;">08</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub New()</span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_205_275_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;">(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> name </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">String</span><span style="color: #000000;">) </span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> _name </span><span style="color: #000000;">=</span><span style="color: #000000;"> name </span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Sub</span></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: #008080;">12</span><span style="color: #000000;"><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Open_Text').style.display='inline';"/> </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Overloads</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Overrides</span><span style="color: #000000;"> </span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function ToString()</span><span id=".AutoIncVB.ZipsTestObject.Vb_TestObject.Vb_1524_43_312_410_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> ToString() </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">String</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"/> </span><span style="color: #0000FF;">Return</span><span style="color: #000000;"> _name </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">/</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> _id.ToString() </span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Function</span></span><span style="color: #000000;"> </span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Class</span></span><span style="color: #000000;"> </span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/></span><span style="color: #0000FF;">End Namespace</span></span></div></pre></div></div> </span> <p>It is only left to register the callback with the creating() event:</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">AutoIncExample.cs: <span class="fscMemberName">RegisterCallback</span></span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64"><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;">public</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;"> RegisterCallback() </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RegisterCallback_1719_64_46_432_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"/> IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer(); </span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> IEventRegistry registry </span><span style="color: #000000;">=</span><span style="color: #000000;"> EventRegistryFactory.ForObjectContainer(db); </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: #008000;">//</span><span style="color: #008000;"> register an event handler, which will assign autoincremented IDs to any </span><span style="color: #008080;">6</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;"> object extending CountedObject, when the object is created</span><span style="color: #008000;"> </span><span style="color: #008080;">7</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> registry.Creating </span><span style="color: #000000;">+=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> CancellableObjectEventHandler(OnCreating); </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">AutoIncExample.cs: <span class="fscMemberName">OnCreating</span></span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58"><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;"> OnCreating(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> sender, CancellableObjectEventArgs args) </span><span style="color: #008080;">02</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_87_374_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"/> IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer(); </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;">object</span><span style="color: #000000;"> obj </span><span style="color: #000000;">=</span><span style="color: #000000;"> args.Object; </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;"> only for the objects extending the CountedObject</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: #0000FF;">if</span><span style="color: #000000;"> (obj </span><span style="color: #0000FF;">is</span><span style="color: #000000;"> CountedObject) </span><span style="color: #008080;">07</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_OnCreating_1785_58_292_364_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"/> ((CountedObject)obj).Id </span><span style="color: #000000;">=</span><span style="color: #000000;"> GetNextId(db); </span><span style="color: #008080;">09</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;">10</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">AutoIncExample.cs: <span class="fscMemberName">GetNextId</span></span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53"><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;">int</span><span style="color: #000000;"> GetNextId(IObjectContainer db) </span><span style="color: #008080;">02</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_GetNextId_1843_53_58_324_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"/> </span><span style="color: #008000;">//</span><span style="color: #008000;"> this function retrieves the next available ID from </span><span style="color: #008080;">04</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;"> the IncrementedId object</span><span style="color: #008000;"> </span><span style="color: #008080;">05</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> IncrementedId r </span><span style="color: #000000;">=</span><span style="color: #000000;"> IncrementedId.GetIdObject(db); </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;">int</span><span style="color: #000000;"> nRoll; </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> nRoll </span><span style="color: #000000;">=</span><span style="color: #000000;"> r.GetNextID(db); </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: #008080;">09</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;"> nRoll; </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><br></p> </span> <span name="cs_wiki_filter" csw_filters="vb"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">AutoIncExample.vb: <span class="fscMemberName">RegisterCallback</span></span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_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=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub RegisterCallback()</span><span id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RegisterCallback_1984_64_14_420_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> RegisterCallback() </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;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer() </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: #008000;">'</span><span style="color: #008000;"> register an event handler, which will assign autoincremented IDs to any</span><span style="color: #008000;"> </span><span style="color: #008080;">4</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;"> object extending CountedObject, when the object is created</span><span style="color: #008000;"> </span><span style="color: #008080;">5</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> registry </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IEventRegistry </span><span style="color: #000000;">=</span><span style="color: #000000;"> EventRegistryFactory.ForObjectContainer(db) </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">AddHandler</span><span style="color: #000000;"> registry.Creating, </span><span style="color: #0000FF;">AddressOf</span><span style="color: #000000;"> OnCreating </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><div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">AutoIncExample.vb: <span class="fscMemberName">OnCreating</span></span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_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=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub OnCreating()</span><span id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_OnCreating_2048_54_15_401_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> OnCreating(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> sender </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><span style="color: #000000;">, </span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> args </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> CancellableObjectEventArgs) </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;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer </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;"> obj </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> args.Object </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: #008000;">'</span><span style="color: #008000;"> only for the objects extending the CountedObject</span><span style="color: #008000;"> </span><span style="color: #008080;">5</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> </span><span style="color: #0000FF;">TypeOf</span><span style="color: #000000;"> obj </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> CountedObject </span><span style="color: #0000FF;">Then</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"/> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(obj, CountedObject).Id </span><span style="color: #000000;">=</span><span style="color: #000000;"> GetNextId(db) </span><span style="color: #008080;">7</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;">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> <br></p> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">AutoIncExample.vb: <span class="fscMemberName">GetNextId</span></span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_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=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function GetNextId()</span><span id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_GetNextId_2113_53_15_361_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> GetNextId(</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;"> </span><span style="color: #0000FF;">Integer</span><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"/> </span><span style="color: #008000;">'</span><span style="color: #008000;"> this function retrieves the next available ID from </span><span style="color: #008000;"> </span><span style="color: #008080;">3</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;"> the IncrementedId object</span><span style="color: #008000;"> </span><span style="color: #008080;">4</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> r </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IncrementedId </span><span style="color: #000000;">=</span><span style="color: #000000;"> IncrementedId.GetIdObject(db) </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;">Dim</span><span style="color: #000000;"> nRoll </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</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"/> nRoll </span><span style="color: #000000;">=</span><span style="color: #000000;"> r.GetNextID(db) </span><span style="color: #008080;">7</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;"> nRoll </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 Function</span></span></div></pre></div></div> <br> </p> </span> <p>You can test the results with the following code:</p><span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">AutoIncExample.cs: <span class="fscMemberName">StoreObjects</span></span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60"><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;">public</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;"> StoreObjects() </span><span style="color: #008080;">02</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_StoreObjects_2313_60_42_362_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"/> IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer(); </span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> TestObject test; </span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> test </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> TestObject(</span><span style="color: #800000;">"</span><span style="color: #800000;">FirstObject</span><span style="color: #800000;">"</span><span style="color: #000000;">); </span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(test); </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> test </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> TestObject(</span><span style="color: #800000;">"</span><span style="color: #800000;">SecondObject</span><span style="color: #800000;">"</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"/> db.Set(test); </span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> test </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> TestObject(</span><span style="color: #800000;">"</span><span style="color: #800000;">ThirdObject</span><span style="color: #800000;">"</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"/> db.Set(test); </span><span style="color: #008080;">11</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">AutoIncExample.cs: <span class="fscMemberName">RetrieveObjects</span></span></div><div class="fscCode"><pre ID=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63"><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;">public</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;"> RetrieveObjects() </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Open_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Closed_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Closed_Text').style.display='inline';"/><img id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Closed_Text').style.display='none'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Open_Image').style.display='inline'; document.getElementById('.AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Open_Text').style.display='inline';"/> </span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id=".AutoIncCS.ZipsAutoIncExample.Cs_AutoIncExample.Cs_RetrieveObjects_2375_63_45_201_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"/> IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer(); </span><span style="color: #008080;">4</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;"> TestObject(</span><span style="color: #0000FF;">null</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"/> ListResult(result); </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></span> <span name="cs_wiki_filter" csw_filters="vb"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">AutoIncExample.vb: <span class="fscMemberName">StoreObjects</span></span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">01</span><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_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=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub StoreObjects()</span><span id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_StoreObjects_2508_60_14_361_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> StoreObjects() </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;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer </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;"> test </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TestObject </span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> test </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> TestObject(</span><span style="color: #800000;">"</span><span style="color: #800000;">FirstObject</span><span style="color: #800000;">"</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"/> db.Set(test) </span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> test </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> TestObject(</span><span style="color: #800000;">"</span><span style="color: #800000;">SecondObject</span><span style="color: #800000;">"</span><span style="color: #000000;">) </span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(test) </span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> test </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> TestObject(</span><span style="color: #800000;">"</span><span style="color: #800000;">ThirdObject</span><span style="color: #800000;">"</span><span style="color: #000000;">) </span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> db.Set(test) </span><span style="color: #008080;">10</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><div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">AutoIncExample.vb: <span class="fscMemberName">RetrieveObjects</span></span></div><div class="fscCode"><pre ID=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Open_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Closed_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Closed_Text').style.display='inline';"/><img id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Closed_Text').style.display='none'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Open_Image').style.display='inline'; document.getElementById('.AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_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=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub RetrieveObjects()</span><span id=".AutoIncVB.ZipsAutoIncExample.Vb_AutoIncExample.Vb_RetrieveObjects_2568_59_14_208_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> RetrieveObjects() </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;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer </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;"> 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;"> TestObject(</span><span style="color: #0000FF;">Nothing</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"/> 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 style="color: #0000FF;">End Sub</span></span></div></pre></div></div> <br> </p></span> Please, note that the suggested implementation <b>cannot be used in a multithreaded environment</b>. In such environment you will have to make sure that the IncrementedId class can only be saved to the database once, and that 2 threads cannot independently and simultaneously increment IncrementedId counter.</div> </div> <div id="footer"> This revision (5) was last Modified 2007-05-07T10:09:51 by Tetyana. </div> </body> </html>