Sophie

Sophie

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

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

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Simple Persistence</title>
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Simple Persistence</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 makes your work with persistent objects very simple and 
straightforward. The only #store(object) method is used for both saving and 
modification of any object that exists in your model.</p>



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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.cs: <span class="fscMemberName">StorePilot</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54"><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;"> StorePilot()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_34_407_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"/>      File.Delete(YapFileName);
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(YapFileName);
</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;">try</span><span style="color: #000000;">
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_135_341_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"/>        Pilot pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">0</span><span style="color: #000000;">);
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Set(pilot);
</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: #008000;">//</span><span style="color: #008000;"> change pilot and resave updated</span><span style="color: #008000;">
</span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">        pilot.AddPoints(</span><span style="color: #800080;">10</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"/>        db.Set(pilot);
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Stored {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, pilot);
</span><span style="color: #008080;">13</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;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_StorePilot_264_54_357_379_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">17</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;">18</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      RetrieveAllPilots();
</span><span style="color: #008080;">19</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">QueryExample.cs: <span class="fscMemberName">UpdatePilotWrong</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56"><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;"> UpdatePilotWrong()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_40_448_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"/>      StorePilot();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(YapFileName);
</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;">try</span><span style="color: #000000;">
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_129_382_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: #008000;">//</span><span style="color: #008000;"> Even completely identical Pilot object
</span><span style="color: #008080;">08</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;"> won't work for update of the saved pilot</span><span style="color: #008000;">
</span><span style="color: #008080;">09</span><span style="color: #008000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">        Pilot pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">,</span><span style="color: #800080;">0</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"/>        pilot.AddPoints(</span><span style="color: #800080;">11</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"/>        db.Set(pilot);
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Added 11 points to {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, pilot);
</span><span style="color: #008080;">13</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;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilotWrong_322_56_398_420_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">17</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;">18</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      RetrieveAllPilots();
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div> </p>

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.cs: <span class="fscMemberName">UpdatePilot</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55"><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;"> UpdatePilot()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_35_453_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"/>      StorePilot();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(YapFileName);
</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;">try</span><span style="color: #000000;">
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_124_387_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: #008000;">//</span><span style="color: #008000;"> first retrieve the object from the database</span><span style="color: #008000;">
</span><span style="color: #008080;">08</span><span style="color: #008000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">        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;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">,</span><span style="color: #800080;">10</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"/>        Pilot found</span><span style="color: #000000;">=</span><span style="color: #000000;">(Pilot)result.Next();
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        found.AddPoints(</span><span style="color: #800080;">11</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"/>        db.Set(found);
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Added 11 points to {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, found);
</span><span style="color: #008080;">13</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;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_UpdatePilot_387_55_403_425_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">17</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;">18</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      RetrieveAllPilots();
</span><span style="color: #008080;">19</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">QueryExample.vb: <span class="fscMemberName">StorePilot</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_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="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub StorePilot()</span><span id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_StorePilot_506_54_14_601_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> StorePilot()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            File.Delete(YapFileName)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(YapFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">0</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(pilot)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Stored {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, pilot)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;"> change pilot and resave updated</span><span style="color: #008000;">
</span><span style="color: #008080;">09</span><span style="color: #008000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                pilot.AddPoints(</span><span style="color: #800080;">10</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(pilot)
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Stored {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, pilot)
</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;">Finally</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"/>                db.Close()
</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;">Try</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"/>            RetrieveAllPilots()
</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 Sub</span></span></div></pre></div></div>

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.vb: <span class="fscMemberName">UpdatePilotWrong</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_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="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub UpdatePilotWrong()</span><span id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilotWrong_564_56_14_576_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> UpdatePilotWrong()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            StorePilot()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(YapFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;">Even completely identical Pilot object</span><span style="color: #008000;">
</span><span style="color: #008080;">06</span><span style="color: #008000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #008000;">'</span><span style="color: #008000;"> won't work for update of the saved pilot</span><span style="color: #008000;">
</span><span style="color: #008080;">07</span><span style="color: #008000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">10</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"/>                pilot.AddPoints(</span><span style="color: #800080;">10</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(pilot)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Stored {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, pilot)
</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;">Finally</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"/>                db.Close()
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            RetrieveAllPilots()
</span><span style="color: #008080;">15</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> </p>


<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.vb: <span class="fscMemberName">UpdatePilot</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_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="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub UpdatePilot()</span><span id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_UpdatePilot_631_55_14_604_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> UpdatePilot()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            StorePilot()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(YapFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;">first retrieve the object from the database</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;">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;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">10</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: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(result(</span><span style="color: #800080;">0</span><span style="color: #000000;">), Pilot)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                pilot.AddPoints(</span><span style="color: #800080;">10</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(pilot)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Added 10 points to {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, pilot)
</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;">Finally</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"/>                db.Close()
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            RetrieveAllPilots()
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>Deletion is just as easy:</p>



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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.cs: <span class="fscMemberName">DeletePilot</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55"><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;"> DeletePilot() 
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_36_422_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"/>      StorePilot();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db</span><span style="color: #000000;">=</span><span style="color: #000000;">Db4oFactory.OpenFile(YapFileName);
</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;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_124_355_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: #008000;">//</span><span style="color: #008000;"> first retrieve the object from the database</span><span style="color: #008000;">
</span><span style="color: #008080;">08</span><span style="color: #008000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">        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;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">,</span><span style="color: #800080;">10</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"/>        Pilot found</span><span style="color: #000000;">=</span><span style="color: #000000;">(Pilot)result.Next();
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Delete(found);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Deleted </span><span style="color: #800000;">&quot;</span><span style="color: #000000;">+</span><span style="color: #000000;">found);
</span><span style="color: #008080;">12</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;">13</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecyclequeriesCS.ZipsQueryExample.Cs_QueryExample.Cs_DeletePilot_790_55_372_394_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"/>        db.Close();
</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"/>      RetrieveAllPilots();
</span><span style="color: #008080;">18</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">QueryExample.vb: <span class="fscMemberName">DeletePilot</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_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="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub DeletePilot()</span><span id="ResourcesReferenceObject_LifecyclequeriesVB.ZipsQueryExample.Vb_QueryExample.Vb_DeletePilot_909_55_14_560_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> DeletePilot()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            StorePilot()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(YapFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;">first retrieve the object from the database</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;">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;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800080;">10</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: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(result(</span><span style="color: #800080;">0</span><span style="color: #000000;">), Pilot)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Delete(pilot)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Deleted {0}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, pilot)
</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;">Finally</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"/>                db.Close()
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</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"/>            RetrieveAllPilots()
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>The objects are identified by their references in an application cache. You do not need to implement any additional identification systems (like primary keys 
in RDBMS). See <a href="../basic_concepts/object_identity.html" class="wikiLink">Identity chapter</a> for 
details. The uniqueness of an object is defined only by its reference, if you 
will create 2 objects of the same class with exactly the same fields and save 
them to db4o - you will get 2 objects in your database. As you can see from the 
examples an object instance should be retrieved from the database 
before updating or deleting or you can use the newly created object if it was 
stored in the same session. Creating a new instance identical to the object in the 
database and saving it, will create a new object in the database.</p>

<p>Db4o does 
all the "dirty" work of objects transition between your classes and 
persistent state using <a href="../implementation_strategies/db4o_reflection_api.html" class="wikiLink">Reflection</a> . No 
mappings or additional coding is needed from your side. If you will need to 
change your application model for the next version you will also be surprised 
with the simplicity: all the changes are done in one place - your code, and the 
most common operations are done completely automatically (see <a href="../implementation_strategies/refactoring_and_schema_evolution.html" class="wikiLink">Refactoring 
And Schema Evolution</a> chapter for details).</p><p>Please, remember that all db4o work is done within <a href="../basic_concepts/transaction.html" class="wikiLink">Transaction</a>, which can be committed or rolled back depending on the result you want to achieve.&nbsp;</p></div>
    </div>
    <div id="footer">
					This revision (14) was last Modified 2008-01-28T06:11:53 by Tetyana.
				</div>
  </body>
</html>