<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Leon Zandman's Blog</title>
	<atom:link href="http://www.wirwar.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wirwar.com/blog</link>
	<description>Blah blah SharePoint blah blah Development blah blah</description>
	<pubDate>Tue, 26 Aug 2008 11:19:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Portal Navigation Properties Feature</title>
		<link>http://www.wirwar.com/blog/2008/08/26/portal-navigation-properties-feature/</link>
		<comments>http://www.wirwar.com/blog/2008/08/26/portal-navigation-properties-feature/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 10:02:26 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[sharepoint]]></category>

		<category><![CDATA[feature]]></category>

		<category><![CDATA[navigation]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/?p=77</guid>
		<description><![CDATA[Today my colleague Harmjan Greving pointed me to the Portal Navigation Properties Feature. I had never encountered this one before and as it turns out it is surprisingly undocumented by Microsoft.
So what does it do? Well, it&#8217;s a feature that comes with MOSS 2007 (unfortunately it isn&#8217;t included with WSS 3.0) that enables you to [...]]]></description>
			<content:encoded><![CDATA[<p>Today my colleague <a href="http://www.dynasign.nl/blog/" target="_blank">Harmjan Greving</a> pointed me to the Portal Navigation Properties Feature. I had never encountered this one before and as it turns out it is surprisingly undocumented by Microsoft.</p>
<p>So what does it do? Well, it&#8217;s a feature that comes with MOSS 2007 (unfortunately it isn&#8217;t included with WSS 3.0) that enables you to define per-site navigation settings in a declarative way. Until now I always used to write custom API code for this, that I executed from a feature receiver or a custom site provisioning provider.</p>
<p>The Portal Navigation Properties Feature itself is actually very simple. It contains no elements, but is only used to trigger the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.navigationfeaturehandler.aspx" target="_blank">Microsoft.SharePoint.Publishing.NavigationFeatureHandler</a> feature receiver, which does the real work, based on properties you specify. It is typically used from within a site definition file (ONET.XML), like this:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">...</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">WebFeatures</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Feature</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">=&#8221;541F5F57-C847-4e16-B59A-B31E90E6F9EA&#8221;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">&lt;!&#8211; Portal Navigation Properties Feature &#8211;&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">&lt;</span><span style="color: #800000">Properties</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">=&#8221;http://schemas.microsoft.com/sharepoint/&#8221;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Key</span><span style="color: #0000ff">=&#8221;InheritGlobalNavigation&#8221;</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">=&#8221;True&#8221;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Key</span><span style="color: #0000ff">=&#8221;InheritCurrentNavigation&#8221;</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">=&#8221;True&#8221;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Key</span><span style="color: #0000ff">=&#8221;IncludeSubSites&#8221;</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">=&#8221;True&#8221;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Key</span><span style="color: #0000ff">=&#8221;IncludePages&#8221;</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">=&#8221;False&#8221;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Key</span><span style="color: #0000ff">=&#8221;OrderingMethod&#8221;</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">=&#8221;Automatic&#8221;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Key</span><span style="color: #0000ff">=&#8221;AutomaticSortingMathod&#8221;</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">=&#8221;CreatedDate&#8221;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Properties</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Feature</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">WebFeatures</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">...</pre>
</div>
</div>
<p>Using <a href="http://www.red-gate.com/products/reflector/" target="_blank">Reflector</a> I found out the following properties can be used with this feature:</p>
<table cellspacing="2" cellpadding="2" width="413" border="1">
<tbody>
<tr>
<td valign="top" align="middle" width="181"><strong>Property</strong></td>
<td valign="top" align="middle" width="224"><strong>Valid Values</strong></td>
</tr>
<tr>
<td valign="top" width="181">IncludeInCurrentNavigation</td>
<td valign="top" width="224">True / False</td>
</tr>
<tr>
<td valign="top" width="181">InheritGlobalNavigation</td>
<td valign="top" width="224">True / False</td>
</tr>
<tr>
<td valign="top" width="181">InheritCurrentNavigation</td>
<td valign="top" width="224">True / False</td>
</tr>
<tr>
<td valign="top" width="181">ShowSiblings</td>
<td valign="top" width="224">True / False</td>
</tr>
<tr>
<td valign="top" width="181">IncludeSubSites</td>
<td valign="top" width="224">True / False</td>
</tr>
<tr>
<td valign="top" width="181">IncludePages</td>
<td valign="top" width="224">True / False</td>
</tr>
<tr>
<td valign="top" width="181">OrderingMethod</td>
<td valign="top" width="224">Automatic<br />ManualWithAutomaticPageSorting<br />Manual</td>
</tr>
<tr>
<td valign="top" width="181">AutomaticSortingMathod <sup>1</sup></td>
<td valign="top" width="224">Title<br />CreatedDate<br />LastModifiedDate</td>
</tr>
<tr>
<td valign="top" width="181">SortAscending</td>
<td valign="top" width="224">True / False</td>
</tr>
</tbody>
</table>
<p><sup>1</sup> Please note the awful spelling error in &#8220;AutomaticSortingM<strong>a</strong>thod&#8221;. Ofcourse this should have been &#8220;AutomaticSortingM<strong>e</strong>thod&#8221;, but apparently someone at Microsoft forgot to run the spell checker over his/her code <img src='http://www.wirwar.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/08/26/portal-navigation-properties-feature/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Building a SPQuery ViewFields string</title>
		<link>http://www.wirwar.com/blog/2008/08/01/building-a-spquery-viewfields-string/</link>
		<comments>http://www.wirwar.com/blog/2008/08/01/building-a-spquery-viewfields-string/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 12:58:35 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[Handy]]></category>

		<category><![CDATA[developing]]></category>

		<category><![CDATA[sharepoint]]></category>

		<category><![CDATA[SPQuery]]></category>

		<category><![CDATA[viewfields]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/?p=75</guid>
		<description><![CDATA[If you&#8217;re querying SharePoint content using a CAML query from code it&#8217;s a good habit to always populate the SPQuery instance&#8217;s ViewFields property. Otherwise the returned SPListItem instances might not contain any data for certain fields and throw an exception when you try to access those fields. 
Specifying ViewFields involves creating a string of CAML [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re querying SharePoint content using a CAML query from code it&#8217;s a good habit to always populate the SPQuery instance&#8217;s <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewfields.aspx">ViewFields</a> property. Otherwise the returned SPListItem instances might not contain any data for certain fields and throw an exception when you try to access those fields. </p>
<p>Specifying ViewFields involves creating a string of CAML <a href="http://msdn.microsoft.com/en-us/library/ms442728.aspx">FieldRef</a> elements. For instance if we want our query to return items that contain data for the Title, Created and ID field we use this: </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> &lt;FieldRef Name=<span style="color: #006080">&#8216;Title&#8217;</span>/&gt;&lt;FieldRef Name=<span style="color: #006080">&#8216;Created&#8217;</span>/&gt;&lt;FieldRef Name=<span style="color: #006080">&#8216;ID&#8217;</span>/&gt;</pre>
</p></div>
</div>
<p>As you can see there&#8217;s some overhead of <a href="http://en.wikipedia.org/wiki/Boilerplate_(text)">boilerplate</a> markup involved. I&#8217;ve written a small piece of code that I always use to make my life a little easier. Today I happened to post this code in a <a href="http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/076c57b1-a780-4b86-b00b-849fa8789318">reply</a> I wrote on the MSDN forums and also decided to submit it as <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewfields.aspx#CommunityContent">Community Content</a> to the official SPQuery docs on MSDN. Then I thought I might as well share it with you here. So here it is: </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> BuildViewFieldsXml(<span style="color: #0000ff">params</span> <span style="color: #0000ff">string</span>[] fieldNames)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> TEMPLATE = <span style="color: #006080">@&quot;&lt;FieldRef Name=&#8217;{0:S}&#8217;/&gt;&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     StringBuilder sb = <span style="color: #0000ff">new</span> StringBuilder();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #0000ff">foreach</span> (<span style="color: #0000ff">string</span> fieldName <span style="color: #0000ff">in</span> fieldNames)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         sb.AppendFormat(TEMPLATE, fieldName);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     <span style="color: #0000ff">return</span> sb.ToString();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> <span style="color: #008000">// Use it like this:</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span> SPQuery query = <span style="color: #0000ff">new</span> SPQuery();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> query.ViewFields = BuildViewFieldsXml(<span style="color: #006080">&quot;Title&quot;</span>, <span style="color: #006080">&quot;Created&quot;</span>, <span style="color: #006080">&quot;ID&quot;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span> <span style="color: #008000">// Note that you can specify a variable amount of string parameters, i.e.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span> query.ViewFields = BuildViewFieldsXml(<span style="color: #006080">&quot;Title&quot;</span>, <span style="color: #006080">&quot;Created&quot;</span>, <span style="color: #006080">&quot;ID&quot;</span>, <span style="color: #006080">&quot;Author&quot;</span>, <span style="color: #006080">&quot;Gender&quot;</span>);</pre>
</p></div>
</div>
<p>Yeah, you&#8217;re right. This piece of code isn&#8217;t exactly rocket science. But you might appreciate it anyway <img src='http://www.wirwar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/08/01/building-a-spquery-viewfields-string/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SharePoint Frustrations #1: The undocumented &#34;IncludeTimeValue&#34; CAML attribute</title>
		<link>http://www.wirwar.com/blog/2008/07/30/sharepoint-frustrations-1-the-undocumented-includetimevalue-caml-attribute/</link>
		<comments>http://www.wirwar.com/blog/2008/07/30/sharepoint-frustrations-1-the-undocumented-includetimevalue-caml-attribute/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 15:39:26 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[developing]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[sharepoint]]></category>

		<category><![CDATA[uncategorized]]></category>

		<category><![CDATA[bug]]></category>

		<category><![CDATA[frustrations]]></category>

		<category><![CDATA[IncludeTimeValue]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/?p=74</guid>
		<description><![CDATA[I&#8217;m planning on doing some posts about frustrating things I have encountered (and still do!) during my SharePoint development efforts. Here&#8217;s the first one:
Last year while working on a MOSS 2007 project for one of our customers I stumbled on what I thought was a bug in SharePoint 2007. I had created a custom list [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m planning on doing some posts about frustrating things I have encountered (and still do!) during my SharePoint development efforts. Here&#8217;s the first one:</p>
<p>Last year while working on a MOSS 2007 project for one of our customers I stumbled on what I thought was a bug in SharePoint 2007. I had created a custom list that was filled with Electronic Program Guide (EPG) information for the streaming video media that that site contained. I then created a Webpart that used ASP.Net AJAX to continually show the actual EPG information below the video stream. </p>
<p>In order to obtain the EPG items I used a CAML query to query the EPG list. The list was simply a custom list containing amongst others a column of type DateTime that was called &quot;ProgramEnd&quot;. As the name suggests it contained the time the program ended. I then used the following code to create a query that was supposed to obtain the currently broadcasted item and all future items. </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> EPG_QUERY_TEMPLATE = <span style="color: #006080">@&quot;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> &lt;Where&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>  &lt;Geq&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>   &lt;FieldRef Name=&#8217;ProgramEnd&#8217; /&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>   &lt;Value Type=&#8217;DateTime&#8217;&gt;{0}&lt;/Value&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>  &lt;/Geq&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> &lt;/Where&gt;&quot;</span>; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> SPQuery query = <span style="color: #0000ff">new</span> SPQuery();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> query.Query = String.Format(EPG_QUERY_TEMPLATE,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now)); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> // &#8230;</pre>
</p></div>
</div>
<p>To my surprise this query always returned too many items. Further investigation showed that time part of the query seemed to be ignored completely, so it returned the items as if no time was specified! So instead of getting the current item and all future items it returned all items broadcasted for that day.</p>
<p>After wasting a lot of time debugging, using the <a href="http://www.u2u.be/res/Tools/SharePointCamlQueryBuilder.aspx">U2U Caml Query Builder</a> and looking for an answer / solution on the internet I gave up and wrote a quick hack around it, which fortunately wasn&#8217;t very difficult. It would just run the query and run the results through some additional code that checked the ProgramEnd DateTime field and filter out the wrong items, like this:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> SPListItemCollection results = &#8230;; <span style="color: #008000">// The results from the query mentioned above</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #008000">// Trim the results to only include the current and future items</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> List&lt;SPListItem&gt; trimmedItems = <span style="color: #0000ff">new</span> List&lt;SPListItem&gt;();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #0000ff">foreach</span> (SPListItem result <span style="color: #0000ff">in</span> results)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     DateTime programEnd = (DateTime)result[<span style="color: #006080">&quot;ProgramEnd&quot;</span>];</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     <span style="color: #0000ff">if</span> (programEnd &gt;= DateTime.Now)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         trimmedItems.Add(result);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> } </pre>
</p></div>
</div>
<p>Fortunately this worked just fine and the customer was happy. I was not&#8230; <img src='http://www.wirwar.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>Today while surfing the Net I stumbled on <a href="http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/f891563a-eea2-4525-8a88-b23f0d435930/">this entry</a> in the MSDN forums, from which I learned it wasn&#8217;t a bug, but that you need to included the &quot;IncludeTimeValue&quot; attribute to the CAML query, like this: </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> &lt;Where&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>  &lt;Eq&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>   &lt;FieldRef Name=<span style="color: #006080">&#8216;programEnd&#8217;</span> /&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>   &lt;Value Type=<span style="color: #006080">&#8216;DateTime&#8217;</span> IncludeTimeValue=<span style="color: #006080">&#8216;TRUE&#8217;</span>&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>    2008-07-30T12:00:00Z</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>   &lt;/Value&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>  &lt;/Eq&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> &lt;/Where&gt; </pre>
</p></div>
</div>
<p>If only I had known it was this simple&#8230; What bothers me is that this little, but very important attribute seems to be totally undocumented. I couldn&#8217;t find any information about it in the WSS / SharePoint SDKs.</p>
<p>Ofcourse once I knew what to look for I found <a href="http://nickgrattan.wordpress.com/2008/04/24/filtering-views-by-time-and-date/">some</a> <a href="http://puneetspeed.spaces.live.com/blog/cns!AFAFB88D250BEE36!308.entry">other</a> blogs and forums mentioning this issue. It turns out the UCSharp blog had already <a href="http://ucsharp.wordpress.com/2007/10/11/9/">blogged</a> about this way back in October 2007, only a few months after I searched for it. Even <a href="http://www.u2u.info/Blogs/karine/default.aspx">Karine Bosch</a>, U2U&#8217;s &quot;CAML Girl&quot; and author of the famous U2U CAML Query Builder, <a href="http://www.u2u.info/Blogs/karine/Lists/Posts/ViewPost.aspx?ID=30">says</a> she only recently found out about this. Fortunately she has included support for the &quot;IncludeTimeValue&quot; attribute in her latest version of the U2U Caml Query Builder, which I know a lot of SharePoint developers use to construct and test their CAML queries.</p>
<p>I also noticed that someone called puneetspeed has added some Community Content to the online SharePoint SDK&#8217;s <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.aspx">SPQuery</a> docs explaining this issue. So hopefully Microsoft will add information about the &quot;IncludeTimeValue&quot; attribute to the official SDK text in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/07/30/sharepoint-frustrations-1-the-undocumented-includetimevalue-caml-attribute/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Back from the DevDays 2008</title>
		<link>http://www.wirwar.com/blog/2008/05/23/back-from-the-devdays-2008/</link>
		<comments>http://www.wirwar.com/blog/2008/05/23/back-from-the-devdays-2008/#comments</comments>
		<pubDate>Thu, 22 May 2008 22:05:27 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[developing]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[devdays]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/?p=65</guid>
		<description><![CDATA[Just arrived back from my visit to the Microsoft DevDays 2008 in Amsterdam. It was a great day and I&#8217;ve attended some interesting sessions.
I&#8217;ve uploaded the photos I took to my Flickr account, so check &#8216;em out. I&#8217;ve also uploaded a small video of the &#8220;Holland Sport&#8221; bicycle race track we had at our booth. [...]]]></description>
			<content:encoded><![CDATA[<p>Just arrived back from my visit to the Microsoft DevDays 2008 in Amsterdam. It was a great day and I&#8217;ve attended some interesting sessions.</p>
<p>I&#8217;ve uploaded the photos I took to <a href="http://www.flickr.com/photos/7197016@N04/sets/72157605201831487/">my Flickr account</a>, so check &#8216;em out. I&#8217;ve also uploaded a small video of the &#8220;Holland Sport&#8221; bicycle race track we had at our booth. Check it out:</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/lZ5VPzohnjE&#038;hl=en&#038;rel=0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/lZ5VPzohnjE&#038;hl=en&#038;rel=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p>It was a very tiring day and I&#8217;m going to get some sleep now. I&#8217;ll blog about some more about the DevDays later on&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/05/23/back-from-the-devdays-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Attending Microsoft DevDays 2008</title>
		<link>http://www.wirwar.com/blog/2008/05/21/attending-microsoft-devdays-2008/</link>
		<comments>http://www.wirwar.com/blog/2008/05/21/attending-microsoft-devdays-2008/#comments</comments>
		<pubDate>Wed, 21 May 2008 21:22:50 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[devdays]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/?p=64</guid>
		<description><![CDATA[Tomorrow (well&#8230; in a couple of hours actually) I&#8217;m off to Amsterdam for the Microsoft DevDays 2008. This year I&#8217;m only going to attend the first of the two days. My employer, Atos Origin, is a Platinum sponsor for the event and we&#8217;ll be there with a big booth.
At our booth you&#8217;ll be able to [...]]]></description>
			<content:encoded><![CDATA[<p>Tomorrow (well&#8230; in a couple of hours actually) I&#8217;m off to Amsterdam for the <a href="http://www.devdays.nl/">Microsoft DevDays 2008</a>. This year I&#8217;m only going to attend the first of the two days. My employer, <a href="http://www.atosorigin.nl/">Atos Origin</a>, is a Platinum sponsor for the event and we&#8217;ll be there with a big booth.</p>
<p>At our booth you&#8217;ll be able to compete in a fun bicycle contest and perhaps win one of the six XBOX 360 consoles we are giving away! Hope to see you there. I&#8217;m scheduled for booth duty on thursday morning. Yes, that&#8217;s during <a href="http://suckbusters2.blogspot.com/">David Platt</a>&#8217;s great keynote on &#8220;Why Software Sucks&#8221;. Fortunately I&#8217;ve already seen this one during TechEd Developers 2007 in Barcelona last year and I also own an autographed copy of his book on the topic. But still I&#8217;m going to try to sneak away from the booth for a while <img src='http://www.wirwar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>As for my SharePoint interests I&#8217;m hoping to get a chance to speak with <a href="http://weblogs.asp.net/jan/">Jan Tielens </a>and <a href="http://blog.u2u.info/DottextWeb/patrick/">Patrick Tisseghem</a>, who are both scheduled to speak at the event. I&#8217;ve got some burning questions about Custom Security Trimmers that I hope Patrick can answer.</p>
<p>Oh, and ofcourse I&#8217;ll take my digital camera and see if I can take some nice pictures of the event and post them here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/05/21/attending-microsoft-devdays-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Do not reuse SPQuery!</title>
		<link>http://www.wirwar.com/blog/2008/05/20/do-not-reuse-spquery/</link>
		<comments>http://www.wirwar.com/blog/2008/05/20/do-not-reuse-spquery/#comments</comments>
		<pubDate>Tue, 20 May 2008 21:44:18 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[developing]]></category>

		<category><![CDATA[sharepoint]]></category>

		<category><![CDATA[refactoring]]></category>

		<category><![CDATA[SPQuery]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/?p=59</guid>
		<description><![CDATA[Last week I was refactoring some of my SharePoint code. I stumbled on a loop that created a new SPQuery instance for each iteration. The code was something like this:


   1: SPList list = GetCommentsList();
   2: const string VIEWFIELDS = &#34;&#34;;
   3:&#160; 
   4: foreach (string param [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I was refactoring some of my SharePoint code. I stumbled on a loop that created a new SPQuery instance for each iteration. The code was something like this:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> SPList list = GetCommentsList();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> VIEWFIELDS = <span style="color: #006080">&quot;&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #0000ff">foreach</span> (<span style="color: #0000ff">string</span> param <span style="color: #0000ff">in</span> <span style="color: #0000ff">params</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     <span style="color: #008000">// Create fresh new SPQuery instance&#8230;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     SPQuery query = <span style="color: #0000ff">new</span> SPQuery();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     query.ViewFields = VIEWFIELDS;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     query.Query = BuildQuery(param);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #008000">// And use it&#8230;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>     SPListItemCollection items = list.GetItems(query);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     ProcessItems(items);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> }</pre>
</p></div>
</div>
<p>As the value of the ViewFields property remained the same for each iteration I decided to create just one SPQuery instance and reuse it, like this: </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> SPList list = GetCommentsList();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> VIEWFIELDS = <span style="color: #006080">&quot;&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #008000">// Create just one SPQuery instance&#8230;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> SPQuery query = <span style="color: #0000ff">new</span> SPQuery();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> query.ViewFields = VIEWFIELDS;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> <span style="color: #0000ff">foreach</span> (<span style="color: #0000ff">string</span> param <span style="color: #0000ff">in</span> <span style="color: #0000ff">params</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     <span style="color: #008000">// And reuse it&#8230;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     query.Query = BuildQuery(param);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>     SPListItemCollection items = list.GetItems(query);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     ProcessItems(items);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> }</pre>
</p></div>
</div>
<p>To my surprise this code didn&#8217;t work! The first time the SPQuery instance was used it worked just fine. However, during the next iterations of the foreach loop it didn&#8217;t seem to get updated.</p>
<p>So, what have we learned today? <strong>Never reuse SPQuery instances!</strong> </p>
<p>Well&#8230; That&#8217;s not entirely true. You can reuse SPQuery instances for a very valid reason. If you use the RowLimit property you can limit the number of items returned in the query, which is useful for paging as seen in this sample code (taken from MSDN): </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">using</span> (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     SPList oList = oWebsiteRoot.Lists[<span style="color: #006080">&quot;Announcements&quot;</span>];</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     SPQuery oQuery = <span style="color: #0000ff">new</span> SPQuery();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     oQuery.RowLimit = 10;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">int</span> intIndex = 1;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     <span style="color: #0000ff">do</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         Console.WriteLine(<span style="color: #006080">&quot;Page: &quot;</span> + intIndex);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         SPListItemCollection collListItems = oList.GetItems(oQuery);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         <span style="color: #0000ff">foreach</span>(SPListItem oListItem <span style="color: #0000ff">in</span> collListItems)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>         {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>             Console.WriteLine(oListItem[<span style="color: #006080">&quot;Title&quot;</span>]);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>         oQuery.ListItemCollectionPosition = </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>           collListItems.ListItemCollectionPosition;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         intIndex++;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     } <span style="color: #0000ff">while</span>(oQuery.ListItemCollectionPosition != <span style="color: #0000ff">null</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span> }</pre>
</p></div>
</div>
<p>So, only reuse SPQuery instances if you use paging. If you change the actual CAML query you should create a new SPQuery instance for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/05/20/do-not-reuse-spquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>No More *BEEP*</title>
		<link>http://www.wirwar.com/blog/2008/05/06/no-more-beep/</link>
		<comments>http://www.wirwar.com/blog/2008/05/06/no-more-beep/#comments</comments>
		<pubDate>Mon, 05 May 2008 22:17:53 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[Handy]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[uncategorized]]></category>

		<category><![CDATA[beep]]></category>

		<category><![CDATA[virtual machine]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/?p=57</guid>
		<description><![CDATA[I might have happened to you too: make some error in a Windows virtual machine and your system will *BEEP* out loud. Not some nice and fancy WAV/MP3 sample, but a raw *BEEP* coming straight from your system&#8217;s motherboard. This *BEEP* does not respect your speaker volume and mute settings. And it will probably irritate [...]]]></description>
			<content:encoded><![CDATA[<p>I might have happened to you too: make some error in a Windows virtual machine and your system will *BEEP* out loud. Not some nice and fancy WAV/MP3 sample, but a raw *BEEP* coming straight from your system&#8217;s motherboard. This *BEEP* does not respect your speaker volume and mute settings. And it will probably irritate most people who sit near you.</p>
<p>Fortunately getting the beep to shut up forever is relatively simple. Here&#8217;s how to do it:</p>
<ol>
<li>Open a Command Prompt window (in Vista make sure you open it using the &#8220;Run as administrator&#8221; option).</li>
<li>Use the following commands:</li>
<ul>
<li>To stop the Windows Beep Service:<br /><code>net stop beep</code></li>
<li>To make sure it never gets started again:<br /><code>sc config beep start= disabled</code></li>
</ul>
</ol>
<p>That should take care of them BEEPs <img src='http://www.wirwar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/05/06/no-more-beep/feed/</wfw:commentRss>
		</item>
		<item>
		<title>.NET 3.5 Enhancements Training Kit</title>
		<link>http://www.wirwar.com/blog/2008/04/17/net-35-enhancements-training-kit/</link>
		<comments>http://www.wirwar.com/blog/2008/04/17/net-35-enhancements-training-kit/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 22:48:44 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[developing]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[.net 3.5]]></category>

		<category><![CDATA[training kit]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/2008/04/17/net-35-enhancements-training-kit/</guid>
		<description><![CDATA[The Visual Studio &#038; .NET Framework Evangelism team did it again. After their cool .NET 3.5 Training Kit they are now working on the follow up: the .NET 3.5 Enhancements Training Kit. It&#8217;s not final yet, but still very interesting!
Currently, the training kit contains six hands-on labs, made up of the following technologies:

ADO.NET Data Services
ADO.NET [...]]]></description>
			<content:encoded><![CDATA[<p>The Visual Studio &#038; .NET Framework Evangelism team did it again. After their cool <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8BDAA836-0BBA-4393-94DB-6C3C4A0C98A1&#038;displaylang=en">.NET 3.5 Training Kit</a> they are now working on the follow up: the <a href="http://go.microsoft.com/?linkid=8719735">.NET 3.5 Enhancements Training Kit</a>. It&#8217;s not final yet, but still very interesting!</p>
<p>Currently, the training kit contains six hands-on labs, made up of the following technologies:</p>
<ol>
<li>ADO.NET Data Services</li>
<li>ADO.NET Entity Framework</li>
<li>ASP.NET AJAX History</li>
<li>ASP.NET Dynamic Data</li>
<li>ASP.NET MVC</li>
<li>ASP.NET Silverlight controls</li>
</ol>
<p>Read more about it on <a href="http://lostintangent.com/2008/04/16/net-35-enhancements-training-kit/">Jonathan Carter&#8217;s blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/04/17/net-35-enhancements-training-kit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Beware of the SharePoint Memory Leaks!</title>
		<link>http://www.wirwar.com/blog/2008/03/12/beware-of-the-sharepoint-memory-leaks/</link>
		<comments>http://www.wirwar.com/blog/2008/03/12/beware-of-the-sharepoint-memory-leaks/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 00:30:55 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[developing]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[sharepoint]]></category>

		<category><![CDATA[memory leaks]]></category>

		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/2008/03/12/beware-of-the-sharepoint-memory-leaks/</guid>
		<description><![CDATA[Beware of the SharePoint Memory Leaks!
You might not know it, but when developing for SharePoint (either WSS 3.0 or MOSS 2007) it is very easy to cause memory leaks, which can ultimately thrash your SharePoint server&#8217;s performance. The reason for this is that even though your own code might be written using only managed code, [...]]]></description>
			<content:encoded><![CDATA[<p>Beware of the SharePoint Memory Leaks!</p>
<p>You might not know it, but when developing for SharePoint (either WSS 3.0 or MOSS 2007) it is very easy to cause memory leaks, which can ultimately thrash your SharePoint server&#8217;s performance. The reason for this is that even though your own code might be written using only managed code, the SharePoint API still uses unmanaged code in some places. These unmanaged resources have to be explicitly disposed of, especially considering the fact they are living inside an ASP.Net web application (SharePoint) and potentially can have a long lifetime.</p>
<p>The problem is that the SharePoint API doesn&#8217;t always make clear when exactly you have to dispose of objects explicitly. Sometimes it may look like you&#8217;re just inspecting a value of a property, while in the background a whole new object is instantiated, which holds valuable unmanaged resources that should be freed by the caller (you!). Other times you might find yourself disposing an object, only to find out you weren&#8217;t supposed to&#8230;</p>
<p>Way back in June 2006 Microsoft employees Scott Harris and <a href="http://sharepoint.microsoft.com/blogs/mike/default.aspx" target="_blank">Mike Ammerlaan</a> released their article <a href="http://msdn2.microsoft.com/en-us/library/aa973248.aspx" target="_blank"><em>Best Practices: Using Disposable Windows SharePoint Services Objects</em></a> on MSDN, which can be regarded as the <em>mother</em> of all articles on this subject. I think this article is often overlooked and should be considered essential reading material for every serious SharePoint developer out there. Also read their more recent article called <a href="http://msdn2.microsoft.com/en-us/library/bb687949.aspx" target="_blank"><em>Best Practices: Common Coding Issues When Using the SharePoint Object Model</em></a>, which also handles topics like data and object caching and writing scalable code.</p>
<p>Recently two other Microsoft employees also wrote interesting pieces on this subject. <a href="http://blogs.technet.com/stefan_gossner/default.aspx" target="_blank">Stefan Go&#223;ner</a> did a piece called <a href="http://blogs.technet.com/stefan_gossner/archive/2007/11/26/dealing-with-memory-pressure-problems-in-moss-wss.aspx" target="_blank"><em>Dealing with Memory Pressure problems in MOSS/WSS</em></a>, in which he explains what a &quot;Memory Pressure Situation&quot; is and he lists some common causes and solutions for it. The other interesting read came from <a href="http://blogs.msdn.com/rogerla/default.aspx" target="_blank">Roger Lamb</a>. His entry is called <a href="http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx" target="_blank"><em>SharePoint 2007 and WSS 3.0 Dispose Patterns by Example</em></a> and in it he shows some very clear code samples and patterns on how to properly handle SharePoint objects.</p>
<p>Very cool material, guys!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/03/12/beware-of-the-sharepoint-memory-leaks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Return of SmartPart V1.3 released</title>
		<link>http://www.wirwar.com/blog/2008/02/15/return-of-smartpart-v13-released/</link>
		<comments>http://www.wirwar.com/blog/2008/02/15/return-of-smartpart-v13-released/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 15:59:56 +0000</pubDate>
		<dc:creator>Leon Zandman</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[developing]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[sharepoint]]></category>

		<category><![CDATA[web parts]]></category>

		<category><![CDATA[smartpart]]></category>

		<guid isPermaLink="false">http://www.wirwar.com/blog/2008/02/15/return-of-smartpart-v13-released/</guid>
		<description><![CDATA[Yesterday Jan Tielens released a new version of his famous SmartPart to the community. It is now at version 1.3 and here&#8217;s the changelog:

Added a setup wizard to install the Return of SmartPart.
Added sample user controls (including connectable user controls and AJAX user controls).
Added localization support for ASP.NET AJAX user controls.
Various minor bug fixes.
Nice 2-minute [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="http://weblogs.asp.net/jan/archive/2008/02/14/return-of-smartpart-v1-3-for-sharepoint-2007-released.aspx">Jan Tielens</a> released a <a href="http://www.codeplex.com/smartpart/Release/ProjectReleases.aspx?ReleaseId=10697">new version</a> of his famous <a href="http://www.codeplex.com/smartpart">SmartPart</a> to the community. It is now at version 1.3 and here&#8217;s the changelog:</p>
<ul>
<li>Added a setup wizard to install the Return of SmartPart.</li>
<li>Added sample user controls (including connectable user controls and AJAX user controls).</li>
<li>Added localization support for ASP.NET AJAX user controls.</li>
<li>Various minor bug fixes.</li>
<li>Nice 2-minute screencast on how to deploy and test the SmartPart.</li>
<li><a href="http://www.codeplex.com/smartpart/Release/ProjectReleases.aspx?ReleaseId=10706">64 bit version</a> available.</li>
</ul>
<p>Great work, Jan! I also like the fact you&#8217;ve used <a href="http://blog.mondosoft.com/ontolica/Default.aspx">Lars Fastrup</a>&#8217;s <a href="http://www.codeplex.com/sharepointinstaller">SharePoint Solution Installer</a> for deploying SmartPart.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wirwar.com/blog/2008/02/15/return-of-smartpart-v13-released/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
