Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 946

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

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Building SODA Queries</title>
    <link rel="stylesheet" type="text/css" href="../../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Building SODA Queries</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>Let's see how simple QBE queries are expressed with SODA. A new Query 
object is created through the #query() method of the ObjectContainer and we can 
add Constraint instances to it. To find all Pilot instances, we constrain 
the query with the Pilot class object.</p>



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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.cs: <span class="fscMemberName">RetrieveAllPilots</span></span></div><div class="fscCode"><pre ID="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67"><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;"> RetrieveAllPilots()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Open_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Closed_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Closed_Text').style.display='inline';"/><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Closed_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Open_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Open_Text').style.display='inline';"/>    </span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_41_293_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> 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 id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Open_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Closed_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Closed_Text').style.display='inline';"/><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Closed_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Open_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Open_Text').style.display='inline';"/>      </span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_113_251_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Constrain(</span><span style="color: #0000FF;">typeof</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"/>        IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Open_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Closed_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Closed_Text').style.display='inline';"/><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Closed_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Open_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Open_Text').style.display='inline';"/>      </span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrieveAllPilots_332_67_267_289_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/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">RetrieveAllPilots</span></span></div><div class="fscCode"><pre ID="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67"><div><!--

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

--><span style="color: #008080;">01</span><img id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Open_Text').style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Closed_Image').style.display='inline'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Closed_Text').style.display='inline';"/><img id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Closed_Text').style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Open_Image').style.display='inline'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_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="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub RetrieveAllPilots()</span><span id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrieveAllPilots_463_67_14_403_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> RetrieveAllPilots()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</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;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot))
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">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;"> query.Execute()
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</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.Close()
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">11</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>Basically, we are exchanging our 'real' prototype for a meta description of the 
objects we'd like to hunt down: a <b>query graph</b> made up of query nodes and 
constraints. A query node is a placeholder for a candidate object, a constraint 
decides whether to add or exclude candidates from the result.</p>

<p>Our first 
simple graph looks like this.</p>

<p><img src="../graph1.gif"/></p>

<p>We're just asking any candidate object (here: any object in the database) to be 
of type Pilot to aggregate our result.</p>

<p>To retrieve a pilot by name, we 
have to further constrain the candidate pilots by descending to their name field 
and constraining this with the respective candidate String.</p>



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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.cs: <span class="fscMemberName">RetrievePilotByName</span></span></div><div class="fscCode"><pre ID="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69"><div><!--

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

--><span style="color: #008080;">1</span><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> RetrievePilotByName(IObjectContainer db)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Open_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Closed_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Closed_Text').style.display='inline';"/><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Closed_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Open_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Open_Text').style.display='inline';"/>    </span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByName_1321_69_62_254_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      query.Constrain(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot));
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_name</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</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: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      ListResult(result);
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.vb: <span class="fscMemberName">RetrievePilotByName</span></span></div><div class="fscCode"><pre ID="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69"><div><!--

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

--><span style="color: #008080;">1</span><img id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Open_Text').style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Closed_Image').style.display='inline'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Closed_Text').style.display='inline';"/><img id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Closed_Text').style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Open_Image').style.display='inline'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_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="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub RetrievePilotByName()</span><span id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByName_1454_69_14_325_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> RetrievePilotByName(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot))
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_name</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</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: #008080;">5</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute()
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            ListResult(result)
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>What does 'descend' mean here? Well, just as we did in our 'real' prototypes, we 
can attach constraints to child members of our candidates.</p>

<p><img src="../graph2.gif"/></p>

<p>So a candidate needs to be of type Pilot and have a member named 'name'that is 
equal to the given String to be accepted for the result.</p>

<p>Note that the 
class constraint is not required: If we left it out, we would query for all 
objects that contain a 'name' member with the given value. In most cases this 
will not be the desired behavior, though.</p>

<p>Finding a pilot by exact points 
is analogous.We just have to cross the Java primitive/object divide.</p>



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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.cs: <span class="fscMemberName">RetrievePilotByExactPoints</span></span></div><div class="fscCode"><pre ID="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76"><div><!--

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

--><span style="color: #008080;">1</span><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> RetrievePilotByExactPoints(IObjectContainer db)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Open_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Closed_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Closed_Text').style.display='inline';"/><img id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Closed_Text').style.display='none'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Open_Image').style.display='inline'; document.getElementById('....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Open_Text').style.display='inline';"/>    </span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....QueriesCS.ZipsQueryExample.Cs_QueryExample.Cs_RetrievePilotByExactPoints_2265_76_69_246_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      query.Constrain(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot));
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800080;">100</span><span style="color: #000000;">);
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      ListResult(result);
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">QueryExample.vb: <span class="fscMemberName">RetrievePilotByExactPoints</span></span></div><div class="fscCode"><pre ID="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76"><div><!--

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

--><span style="color: #008080;">1</span><img id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Open_Text').style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Closed_Image').style.display='inline'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Closed_Text').style.display='inline';"/><img id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Closed_Text').style.display='none'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Open_Image').style.display='inline'; document.getElementById('....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_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="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub RetrievePilotByExactPoints()</span><span id="....QueriesVB.ZipsQueryExample.Vb_QueryExample.Vb_RetrievePilotByExactPoints_2405_76_14_317_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> RetrievePilotByExactPoints(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot))
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800080;">100</span><span style="color: #000000;">)
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </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;"> query.Execute()
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            ListResult(result)
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span></div>
    </div>
    <div id="footer">
					This revision (2) was last Modified 2008-03-02T14:25:40 by Tetyana.
				</div>
  </body>
</html>