<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="120" MadCap:lastWidth="624" MadCap:disableMasterStylesheet="true" MadCap:tocPath="Tuning|Utility Methods" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem"> <head><title>IsStored </title> <script type="text/javascript">/* <![CDATA[ */ window.onload = function(){ var pathToFlash = $('html').attr('MadCap:PathToHelpSystem') + 'Content/Resources/Code/ZeroClipboard.swf'; ZeroClipboard.setMoviePath(pathToFlash); function bindToClipBord(element,content){ var clip = new ZeroClipboard.Client(); clip.setText(content); clip.glue(element); }; if(location.protocol==='file:'){ $('.copylink-marker').remove(); } else{ $('.copylink-marker').each(function(){ var text = $(this).parent().parent().children('.prettyprint').html(); $(this).hover(function(){ bindToClipBord(this,text); }, function(){}); }); } prettyPrint(); }; /* ]]> */</script> <link href="../../SkinSupport/MadCap.css" rel="stylesheet" /> <link href="../../Resources/Stylesheets/OnlineStyle.css" rel="stylesheet" /> <script src="../../Resources/Code/prettify.js"> </script> <script src="../../Resources/Code/lang-vb.js"> </script> <script src="../../Resources/Code/jquery.min.js"> </script> <script src="../../Resources/Code/ZeroClipboard.js"> </script> <script src="../../SkinSupport/MadCapAll.js" type="text/javascript"> </script> </head> <body> <p class="MCWebHelpFramesetLink" style="display: none;"><a href="../../../index_CSH.html#tuning/utility_methods/isstored.htm" style="">Open topic with navigation</a> </p> <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../../tuning.htm">Tuning</a><span class="MCBreadcrumbsDivider"> > </span><a class="MCBreadcrumbsLink" href="../utility_methods.htm">Utility Methods</a><span class="MCBreadcrumbsDivider"> > </span><span class="MCBreadcrumbs">isstored</span> </div> <p> <script type="text/javascript">/*<![CDATA[*/document.write('<a href="' + location.href +'">'); document.write("Direct Link"); document.write('</a>');/*]]>*/</script> </p> <p> </p> <h1>IsStored</h1> <p>ExtObjectContainer#isStored helps you to define if the object is stored in the database. The following example shows how to use it:</p> <p MadCap:conditions="Global.Primary:java" /> <p MadCap:conditions="Primary..NET,Primary.c#,Primary.All languages"> <pre class="prettyprint" xml:space="preserve">UtilityExample.cs: CheckStored public static void CheckStored() { // create a linked list with length 10 SensorPanel list = new SensorPanel().CreateList(10); File.Delete(Db4oFileName); IObjectContainer db = Db4oFactory.OpenFile(Db4oFileName); try { // store all elements with one statement, since all elements are new db.Store(list); Object sensor = (Object)list.Sensor; SensorPanel sp5 = list.Next.Next.Next.Next; System.Console.WriteLine("Root element "+list+" isStored: " + db.Ext().IsStored(list)); System.Console.WriteLine("Simple type "+sensor+" isStored: " + db.Ext().IsStored(sensor)); System.Console.WriteLine("Descend element "+sp5+" isStored: " + db.Ext().IsStored(sp5)); db.Delete(list); System.Console.WriteLine("Root element "+list+" isStored: " + db.Ext().IsStored(list)); } finally { db.Close(); } }</pre> </p> <p MadCap:conditions="Global.Primary:cs" /> <p> <p MadCap:conditions="Primary..NET,Primary.VB.NET,Primary.All languages"> </p> <pre class="prettyprint lang-vb" xml:space="preserve">UtilityExample.vb: CheckStored Public Shared Sub CheckStored() ' create a linked list with length 10 Dim list As SensorPanel = New SensorPanel().CreateList(10) File.Delete(Db4oFileName) Dim db As IObjectContainer = Db4oFactory.OpenFile(Db4oFileName) Try ' store all elements with one statement, ' since all elements are new db.Store(list) Dim sensor As Object = CType(list.Sensor, Object) Dim sp5 As SensorPanel = list.NextSensor.NextSensor. _ NextSensor.NextSensor System.Console.WriteLine("Root element " + list.ToString() _ + " isStored: " + db.Ext().IsStored(list).ToString()) System.Console.WriteLine("Simple type " + sensor.ToString() _ + " isStored: " + db.Ext().IsStored(sensor).ToString()) System.Console.WriteLine("Descend element " + sp5.ToString() _ + " isStored: " + db.Ext().IsStored(sp5).ToString()) db.Delete(list) System.Console.WriteLine("Root element " + list.ToString() _ + " isStored: " + db.Ext().IsStored(list).ToString()) Finally db.Close() End Try End Sub</pre> <p> </p> <p MadCap:conditions="Global.Primary:vb" /> </p> <p MadCap:conditions="Primary.Online">Download example code:</p> <p MadCap:conditions="Primary.Online"> <MadCap:conditionalText MadCap:conditions="Primary..NET,Primary.VB.NET,Primary.All languages"><a href="utilityvb.zip">VB.NET </a> </MadCap:conditionalText> <MadCap:conditionalText MadCap:conditions="Primary..NET,Primary.c#,Primary.All languages"><a href="utilitycs.zip">c# </a> </MadCap:conditionalText> </p> <script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js"> </script> </body> </html>