Sophie

Sophie

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

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

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Native Query Sorting</title>
    <link rel="stylesheet" type="text/css" href="../../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Native Query Sorting</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>Native Query syntax allows you to specify a comparator,
which will be used to sort the results:</p>

<span name="cs_wiki_filter" csw_filters="cs">
<p>c#:&nbsp;</p>
<p><code>IObjectSet Query(Predicate predicate, IComparer comparer);</code></p>
</span>
<span name="cs_wiki_filter" csw_filters="vb">
<p>VB:&nbsp;</p>
<p><code>Function Query(ByVal predicate As Predicate, ByVal comparer As IComparer) As IObjectSet
</code></p>
</span>

<p>In order to get the same results as in <a href="soda_sorting.html" class="wikiLink">SODA Sorting</a>
example we will write the following code:</p>

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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SortingExample.cs: <span class="fscMemberName">GetObjectsNQ</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58"><div><!--

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

--><span style="color: #008080;">01</span><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> GetObjectsNQ()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_43_1179_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(Db4oFileName);
</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="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_143_1093_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"/>                DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Open_Text').style.display='inline';"/>                IList</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Pilot</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> result </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Pilot</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(</span><span style="color: #0000FF;">delegate</span><span style="color: #000000;">(Pilot pilot) </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_269_321_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #0000FF;">true</span><span style="color: #000000;">;
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>                }</span></span><span style="color: #000000;">,
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> System.Comparison</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Pilot</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(</span><span style="color: #0000FF;">delegate</span><span style="color: #000000;">(Pilot p1, Pilot p2)
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Open_Text').style.display='inline';"/>                </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_413_836_Open_Text"><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"/>                    Pilot pilot1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Pilot)p1;
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    Pilot pilot2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Pilot)p2;
</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;">int</span><span style="color: #000000;"> res </span><span style="color: #000000;">=</span><span style="color: #000000;"> pilot1.Points </span><span style="color: #000000;">-</span><span style="color: #000000;"> pilot2.Points;
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (res </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">)
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Open_Text').style.display='inline';"/>                    </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_622_712_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                        </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> pilot1.Name.CompareTo(pilot2.Name);
</span><span style="color: #008080;">18</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;">19</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    </span><span style="color: #0000FF;">else</span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Open_Text').style.display='inline';"/>                    </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_758_818_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                        </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #000000;">res;
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>                    }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>                }</span></span><span style="color: #000000;">));
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                TimeSpan diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">26</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;">Time to execute with NQ and comparator: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms.</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result);
</span><span style="color: #008080;">28</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;">29</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;">30</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingCS.ZipsSortingExample.Cs_SortingExample.Cs_GetObjectsNQ_610_58_1126_1169_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close();
</span><span style="color: #008080;">32</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;">33</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">SortingExample.vb: <span class="fscMemberName">GetObjectsNQ</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub GetObjectsNQ()</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_GetObjectsNQ_730_58_15_614_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> GetObjectsNQ()
</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;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</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;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query(</span><span style="color: #0000FF;">New</span><span style="color: #000000;"> AllPilots, </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> PilotQueryComparer)
</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;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</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;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">08</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;">Time to execute with NQ and comparator: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms.</span><span style="color: #800000;">&quot;</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"/>                ListResult(result)
</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/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">SortingExample.vb: <span class="fscMemberName">AllPilots</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55"><div><!--

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

--><span style="color: #008080;">1</span><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Class AllPilots</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_8_192_Open_Text"><span style="color: #0000FF;">Class</span><span style="color: #000000;"> AllPilots
</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;">Inherits</span><span style="color: #000000;"> Predicate
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Open_Text').style.display='inline';"/>            </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function Match()</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_AllPilots_790_55_74_174_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> Match(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot) </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Boolean</span><span style="color: #000000;">
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Return</span><span style="color: #000000;"> </span><span style="color: #0000FF;">True</span><span style="color: #000000;">
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            </span><span style="color: #0000FF;">End Function</span></span><span style="color: #000000;">
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Class</span></span></div></pre></div></div>
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">SortingExample.vb: <span class="fscMemberName">PilotQueryComparer</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Class PilotQueryComparer</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_8_745_Open_Text"><span style="color: #0000FF;">Class</span><span style="color: #000000;"> PilotQueryComparer
</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;">Implements</span><span style="color: #000000;"> IQueryComparator
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Open_Text').style.display='inline';"/>            </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function Compare()</span><span id="ResourcesReferenceObject_LifecycleQueryingSorting_Query_ResultsSortingVB.ZipsSortingExample.Vb_SortingExample.Vb_PilotQueryComparer_847_60_93_727_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Compare</span><span style="color: #000000;">(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> p1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><span style="color: #000000;">, </span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> p2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><span style="color: #000000;">) </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Implements</span><span style="color: #000000;"> IQueryComparator.Compare
</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;">If</span><span style="color: #000000;"> </span><span style="color: #0000FF;">TypeOf</span><span style="color: #000000;"> p1 </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> Pilot </span><span style="color: #0000FF;">AndAlso</span><span style="color: #000000;"> </span><span style="color: #0000FF;">TypeOf</span><span style="color: #000000;"> p2 </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> Pilot </span><span style="color: #0000FF;">Then</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"/>                    </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot1 </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;">(p1, Pilot)
</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;"> pilot2 </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;">(p2, 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: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> pilot1.Points </span><span style="color: #000000;">-</span><span style="color: #000000;"> pilot2.Points
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> result </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</span><span style="color: #000000;">
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                        </span><span style="color: #0000FF;">Return</span><span style="color: #000000;"> pilot1.Name.CompareTo(pilot2.Name)
</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;">Else</span><span style="color: #000000;">
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                        </span><span style="color: #0000FF;">Return</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #000000;">result
</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;">If</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">If</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"/>                </span><span style="color: #0000FF;">Return</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>            </span><span style="color: #0000FF;">End Function</span></span><span style="color: #000000;">
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Class</span></span></div></pre></div></div> <br></p>


</span>
<p>Advantages of NQ sorting:</p>

<ul>
<li>type-safe queries and sorting, compile-time checking;</li>
<li>ability to implement any custom sorting algorithm</li>
</ul>


<p>The main disadvantage is decreased performance as at current stage <a href="../../../tuning/native_query_optimization.html" class="wikiLink">optimization</a> of sorted Native Queries is not possible.</p></div>
    </div>
    <div id="footer">
					This revision (7) was last Modified 2007-12-17T16:30:08 by Tetyana.
				</div>
  </body>
</html>