Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 2e9c43658e374d290a2de15d25134ac8 > files > 741

db4o-doc-8.0-1.fc15.i686.rpm

<?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="Configuration" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem">
    <head><title>Field Specific Configuration</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#configuration/objectfield_configuration.htm" style="">Open topic with navigation</a>
        </p>
        <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../configuration.htm">Configuration</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Adding a Field Index</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><a name="kanchor58"></a>Field Specific Configuration</h1>
        <p>Some settings are field-specific. It's part of the <a href="objectclass_configuration.htm">object</a>-configuration, which is available on the client, server and embedded-mode of db4o.</p>
        <p>Its recommended that you use the same configuration for the client and the server.</p>
        <h2>Access the Field Configuration</h2>
        <p>The configuration for a field follows the same pattern. First you specify for which type this configuration applies. You pass the type or the name as string. Then you navigate to the specific field by passing the field name as string.</p>
        <p MadCap:conditions="Primary..NET">Note that you need to specify the field-name and not the property-name, also for <a href="../platform_specific_issues/automatic_properties.htm">auto-properties</a>. </p>
        <h2><a name="Adding"></a>Adding a Field Index</h2>
        <p>Index dramatically speed up queries. You should index all fields which you run queries on. <a href="../basics/indexing.htm" target="" title="" alt="" class="MCXref" xrefformat="See &quot;{paratext}&quot;">See "Indexing"</a></p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.ObjectClass(typeof (Person)).ObjectField("name").Indexed(true);</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.cs: Index a certain field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.ObjectClass(GetType(Person)).ObjectField("name").Indexed(True)</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.vb: Index a certain field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <p>As an alternative you also can use the appropriate <span class="PrimaryAnnotation">Attribute</span> on the field which you want to index.</p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">[Indexed]
private string zipCode;</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.cs: Index a field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">&lt;Indexed()&gt; _
Private m_zipCode As String</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.vb: Index a field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <h2><a name="CascadeActivate"></a>Cascade On Activate</h2>
        <p>db4o uses the concept of <a href="../basics/activation.htm">activation</a> to avoid loading to much data into memory. When this setting is turned on, the object referenced by this field is activated, when the object is activated.</p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.ObjectClass(typeof (Person)).ObjectField("father").CascadeOnActivate(true);</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.cs: When activated, activate also the object referenced by this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.ObjectClass(GetType(Person)).ObjectField("father").CascadeOnActivate(True)</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.vb: When activated, activate also the object referenced by this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <h2><a name="CascadeUpdate"></a>Cascade On Update</h2>
        <p>When the object is updated, the object referenced by this field is also updated.</p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.ObjectClass(typeof (Person)).ObjectField("father").CascadeOnUpdate(true);</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.cs: When updated, update also the object referenced by this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.ObjectClass(GetType(Person)).ObjectField("father").CascadeOnUpdate(True)</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.vb: When updated, update also the object referenced by this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <h2><a name="CascadeDelete"></a>Cascade On Delete</h2>
        <p>When the object is deleted, the object referenced by this field is also deleted</p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.ObjectClass(typeof (Person)).ObjectField("father").CascadeOnDelete(true);</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.cs: When deleted, delete also the object referenced by this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.ObjectClass(GetType(Person)).ObjectField("father").CascadeOnDelete(True)</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.vb: When deleted, delete also the object referenced by this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <h2><a name="Rename"></a>Rename Field</h2>
        <p>Allows you to rename this field. . <a href="../advanced_topics/refactoring_and_schema_evolution.htm" target="" title="" alt="" class="MCXref" xrefformat="See &quot;{paratext}&quot;">See "Refactoring and Schema Evolution"</a></p>
        <div class="codesnippet" MadCap:conditions="Primary.c#">
            <pre class="prettyprint" xml:space="preserve">IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.ObjectClass(typeof (Person)).ObjectField("name").Rename("sirname");</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.cs: Rename this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <div class="codesnippet" MadCap:conditions="Primary.VB.NET">
            <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.ObjectClass(GetType(Person)).ObjectField("name").Rename("sirname")</pre>
            <div class="codesnippet-meta">ObjectFieldConfigurations.vb: Rename this field
			<div class="codedownload"><a href="../CodeExamples/configuration/objectfield/Example-configuration-objectfield-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div>
        </div>
        <script type="text/javascript" src="../SkinSupport/MadCapBodyEnd.js">
        </script>
    </body>
</html>