<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>CTICoder</title>
	<atom:link href="http://cticoder.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cticoder.wordpress.com</link>
	<description>A random spillage of programming (and other) thoughts</description>
	<lastBuildDate>Thu, 05 Jan 2012 13:50:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cticoder.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>CTICoder</title>
		<link>http://cticoder.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cticoder.wordpress.com/osd.xml" title="CTICoder" />
	<atom:link rel='hub' href='http://cticoder.wordpress.com/?pushpress=hub'/>
		<item>
		<title>New Year.  New Wallpaper</title>
		<link>http://cticoder.wordpress.com/2010/01/04/new-year-new-wallpaper/</link>
		<comments>http://cticoder.wordpress.com/2010/01/04/new-year-new-wallpaper/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 15:30:27 +0000</pubDate>
		<dc:creator>Shaun McDonnell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2010/01/04/new-year-new-wallpaper/</guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=168&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://cticoder.files.wordpress.com/2010/01/gettowork.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="GetToWork" border="0" alt="GetToWork" src="http://cticoder.files.wordpress.com/2010/01/gettowork_thumb.png?w=1685&#038;h=1055" width="1685" height="1055" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=168&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2010/01/04/new-year-new-wallpaper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d2e543a5b65c844c89c93f8f1e92325?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shaun McDonnell</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2010/01/gettowork_thumb.png" medium="image">
			<media:title type="html">GetToWork</media:title>
		</media:content>
	</item>
		<item>
		<title>Linq2Sql Caching with SqlDependency</title>
		<link>http://cticoder.wordpress.com/2009/11/25/linq2sql-caching-with-sqldependency/</link>
		<comments>http://cticoder.wordpress.com/2009/11/25/linq2sql-caching-with-sqldependency/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 14:35:29 +0000</pubDate>
		<dc:creator>Shaun McDonnell</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[LINQ2SQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2009/11/25/linq2sql-caching-with-sqldependency/</guid>
		<description><![CDATA[It took me a while to figure this one out.&#160; I almost thought it was impossible to implement it in a ‘good way’.&#160; However, extension methods saved the day.&#160; So, if you want to use Sql Service Broker dependencies in your Linq2Sql code, you’ll need an extension method like this: 1: public static List&#60;T&#62; LinqCache&#60;T&#62;(this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=157&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It took me a while to figure this one out.&#160; I almost thought it was impossible to implement it in a ‘good way’.&#160; However, extension methods saved the day.&#160; So, if you want to use Sql Service Broker dependencies in your Linq2Sql code, you’ll need an extension method like this:</p>
<div id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> List&lt;T&gt; LinqCache&lt;T&gt;(<span style="color:#0000ff;">this</span> IQueryable&lt;T&gt; q, DataContext dc, <span style="color:#0000ff;">string</span> key)</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>     SqlDependency.Start(dc.Connection.ConnectionString);</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span>     var cachedItem = (List&lt;T&gt;)HttpContext.Current.Cache.Get(key);</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>&#160; </pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>     <span style="color:#0000ff;">if</span> (cachedItem == <span style="color:#0000ff;">null</span>)</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>     {</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span>         TracingHelper.Write(<span style="color:#006080;">&quot;No cache key [{0}] found for query: {1}&quot;</span>, key, dc.GetCommand(q).CommandText);</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span>         <span style="color:#0000ff;">string</span> connectionString = dc.Connection.ConnectionString;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span>         <span style="color:#0000ff;">string</span> command = dc.GetCommand(q).CommandText;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span>         <span style="color:#0000ff;">using</span> (var sql = <span style="color:#0000ff;">new</span> SqlConnection(connectionString))</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span>         {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span>             sql.Open();</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span>             <span style="color:#0000ff;">using</span> (var cmd = <span style="color:#0000ff;">new</span> SqlCommand(command, sql))</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>             {</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>                 <span style="color:#0000ff;">foreach</span> (DbParameter dbp <span style="color:#0000ff;">in</span> dc.GetCommand(q).Parameters)</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span>                 {</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>                     cmd.Parameters.Add(<span style="color:#0000ff;">new</span> SqlParameter(dbp.ParameterName, dbp.Value));</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>                 }</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span>                 SqlCacheDependencyAdmin.EnableNotifications(connectionString);</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>                 <span style="color:#0000ff;">string</span> notificationTable = q.ElementType.Name;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span>                 <span style="color:#0000ff;">if</span> (!SqlCacheDependencyAdmin.GetTablesEnabledForNotifications(connectionString).Contains(notificationTable))</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span>                     SqlCacheDependencyAdmin.EnableTableForNotifications(connectionString, notificationTable);</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>                 var sqldep = <span style="color:#0000ff;">new</span> SqlCacheDependency(cmd);</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span>                 </pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span>                 cmd.ExecuteNonQuery();</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>                 cachedItem = q.ToList();</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span>                 HttpContext.Current.Cache.Insert(key, cachedItem, sqldep);</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum29">  29:</span>             }</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum30">  30:</span>         }</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum31">  31:</span>     }</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum32">  32:</span>     <span style="color:#0000ff;">else</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum33">  33:</span>     {</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum34">  34:</span>         TracingHelper.Write(<span style="color:#006080;">&quot;Cache key [{0}] FOUND for query:  {1}&quot;</span>, key, dc.GetCommand(q).CommandText);</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum35">  35:</span>     }</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum36">  36:</span>&#160; </pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum37">  37:</span>     SqlDependency.Stop(dc.Connection.ConnectionString);</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum38">  38:</span>     <span style="color:#0000ff;">return</span> cachedItem;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum39">  39:</span> }</pre>
</p></div>
</div>
<div id="codeSnippetWrapper"></div>
<div id="codeSnippetWrapper">
  </div>
<div id="codeSnippetWrapper"></div>
</p>
<p>Now, in order to use this extension method in your queries, you’ll need to do something like this:</p>
<div id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#0000ff;">public</span> List&lt;Company&gt; Get()</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>     <span style="color:#0000ff;">using</span> (var dataContext = <span style="color:#0000ff;">new</span> RoutePointRepositoryDataContext(Db.ConnectionString))</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span>     {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>         var items = dataContext.Companies.LinqCache(dataContext, <span style="color:#006080;">&quot;Companies.All&quot;</span>);</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>         <span style="color:#0000ff;">return</span> items;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>     }</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span> }</pre>
</p></div>
</div>
<div id="codeSnippetWrapper">
  </div>
<div class="csharpcode">
<div id="codeSnippetWrapper"></div>
</div>
<p>The downside is that I haven’t figured out a good way to implement this when retrieving one record from the database.&#160; So, you’ll have to do this:</p>
<div id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#0000ff;">public</span> Company Get(<span style="color:#0000ff;">int</span> id)</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>     <span style="color:#0000ff;">using</span> (var dataContext = <span style="color:#0000ff;">new</span> RoutePointRepositoryDataContext(Db.ConnectionString))</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span>     {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>         var company = dataContext.Companies.Where(c =&gt; c.Id == id).LinqCache(dataContext, <span style="color:#006080;">&quot;Company.Get.&quot;</span> + id.ToString()).Single();</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>         <span style="color:#0000ff;">return</span> company;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>     }</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span> }</pre>
</p></div>
</div>
<div id="codeSnippetWrapper">
  </div>
<div class="csharpcode">
<div id="codeSnippetWrapper"></div>
</div>
<p>&#160;</p>
<p>MSDN did have some code similar to this but it did not work and there were no examples.&#160; This works and and the examples should be enough to get you started.</p>
<p>-Shaun</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=157&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/11/25/linq2sql-caching-with-sqldependency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d2e543a5b65c844c89c93f8f1e92325?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shaun McDonnell</media:title>
		</media:content>
	</item>
		<item>
		<title>A Generic run-time LINQ-based multi-level object sorter</title>
		<link>http://cticoder.wordpress.com/2009/10/26/a-generic-run-time-linq-based-multi-level-object-sorter/</link>
		<comments>http://cticoder.wordpress.com/2009/10/26/a-generic-run-time-linq-based-multi-level-object-sorter/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 05:45:27 +0000</pubDate>
		<dc:creator>Michael Bray</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2009/10/26/a-generic-run-time-linq-based-multi-level-object-sorter/</guid>
		<description><![CDATA[Assume you have a list of objects that has a set of properties.&#160; These properties are stored in a StringCollection or other similar lookup, and you want to sort the objects based on some of these properties, but you don’t know at compile-time which properties to sort on or in what order (that information will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=154&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Assume you have a list of objects that has a set of properties.&#160; These properties are stored in a StringCollection or other similar lookup, and you want to sort the objects based on some of these properties, but you don’t know at compile-time which properties to sort on or in what order (that information will be supplied at run-time, perhaps in configuration).&#160; How do you sort this list, in a manner that honors ascending / descending as well as multi-level sorting rules?&#160; You can’t simply sort the list by each property, since each time you sort, it will wipe out the previous sorting operation.&#160; Of course, LINQ provides sorting thru OrderBy(…) and ThenBy(…) functions that handle the multi-level sort issue.&#160; But it’s a bit more complicated than that, since you don’t know the properties you want to sort on.</p>
<p>Here, I demonstrate a relatively simple generic object sorter that correctly handles multi-level sorting and ascending/descending at each level.</p>
<pre class="code"><span style="color:blue;">private </span><span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; MultiLevelSort&lt;T, SK&gt;(<span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; list, <span style="color:#2b91af;">List</span>&lt;SK&gt; sortKeys, <span style="color:#2b91af;">Func</span>&lt;T, SK, <span style="color:blue;">string</span>&gt; keySelector, <span style="color:#2b91af;">Func</span>&lt;SK, <span style="color:blue;">bool</span>&gt; ascendingSelector)
{
    <span style="color:blue;">if </span>(sortKeys.Count == 0) <span style="color:blue;">return </span>list;

    <span style="color:#2b91af;">IOrderedEnumerable</span>&lt;T&gt; res = <span style="color:blue;">null</span>;
    <span style="color:blue;">for </span>(<span style="color:blue;">int </span>i = 0; i &lt; sortKeys.Count; i++)
    {
        SK sk = sortKeys[i];
        <span style="color:blue;">bool </span>ascending = ascendingSelector(sk);
        <span style="color:blue;">if </span>(i == 0)
        {
            <span style="color:blue;">if </span>(ascending) res = list.OrderBy(r =&gt; keySelector(r, sk));
            <span style="color:blue;">else </span>res = list.OrderByDescending(r =&gt; keySelector(r, sk));
        }
        <span style="color:blue;">else
        </span>{
            <span style="color:blue;">if </span>(ascending) res = res.ThenBy(r =&gt; keySelector(r, sk));
            <span style="color:blue;">else </span>res = res.ThenByDescending(r =&gt; keySelector(r, sk));
        }
    }
    <span style="color:blue;">return </span>res;
}</pre>
<p>This function takes 4 parameters:</p>
<ol>
<li>An IEnumerable&lt;T&gt; of objects to sort </li>
<li>A List&lt;SK&gt; of objects that contain sorting order information (note that this list itself is expected to already be in the correct sort order) </li>
<li>A Func&lt;T, SK, string&gt; to extract the value from T based on information in SK to actually sort on </li>
<li>A Func&lt;SK, bool&gt; to extract the ascending/descending information from SK </li>
</ol>
<p>…and it returns the list correctly sorted as an IEnumerable&lt;T&gt;.&#160; Note that the actual object returned is actually an IOrderedEnumerable&lt;T&gt; as long as there is at least one valid sort key.</p>
<p>This code could then be used as such:</p>
<pre class="code"><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MyProperty</span>&gt; sortProps = AllProperties.Where(sp =&gt; sp.Sort != <span style="color:blue;">string</span>.Empty).OrderBy(sp =&gt; sp.SortOrder).ToList();
<span style="color:blue;">IEnumerable&lt;<span style="color:#2b91af;">MyObject&gt; sortedResults = </span></span>MultiLevelSort&lt;<span style="color:#2b91af;">MyObject</span>, <span style="color:#2b91af;">MyProperty</span>&gt;(
    results, sortProps,
    (r, pe) =&gt; r.Properties.ContainsKey(pe.Name) ? r.Properties[pe.Name] : <span style="color:blue;">string</span>.Empty,
    pe =&gt; pe.Sort == <span style="color:#a31515;">&quot;Ascending&quot;
        </span>).ToList();</pre>
<p>Where MyObject is an object that contains a StringCollection called ‘Properties’, and MyProperty is an object that contains properties called ‘Sort’ (“Ascending/Descending”), ‘SortOrder’ (an integer), and ‘Name’ (the name of the property within the MyObject.Properties collection that we want to sort on).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=154&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/10/26/a-generic-run-time-linq-based-multi-level-object-sorter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/925135adb117b6fd6a194853ddd0425c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbray</media:title>
		</media:content>
	</item>
		<item>
		<title>Simulating VS.net&#8217;s MSI InstallURL property with WiX</title>
		<link>http://cticoder.wordpress.com/2009/10/24/simulating-vs-nets-msi-installurl-property-with-wix/</link>
		<comments>http://cticoder.wordpress.com/2009/10/24/simulating-vs-nets-msi-installurl-property-with-wix/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 06:09:17 +0000</pubDate>
		<dc:creator>Michael Bray</dc:creator>
				<category><![CDATA[WiX]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/?p=150</guid>
		<description><![CDATA[I recently converted several installers from VS.net to WiX.  In one of those installers, I was using a Registry Search condition to check to see if MSXML6 was installed, since the application requires it.  If it wasn’t installed, I was using Visual Studio’s InstallURL property to redirect the user to the Microsoft download page for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=150&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently converted several installers from VS.net to WiX.  In one of those installers, I was using a Registry Search condition to check to see if MSXML6 was installed, since the application requires it.  If it wasn’t installed, I was using Visual Studio’s InstallURL property to redirect the user to the Microsoft download page for the package so they could download and install it.</p>
<p>WiX doesn’t appear to have an InstallURL property available by default, but you can simulate it with some custom actions.   Along the way I learned quite a bit about how WiX structures CustomActions, and experienced quite a bit of frustration getting it to work.  The first step to simulating the InstallURL capability is to set up a Property that searches the registry for the MSXML key:</p>
<pre class="code"><span style="color:blue;">&lt;</span><span style="color:#a31515;">Property </span><span style="color:red;">Id</span><span style="color:blue;">=</span>"<span style="color:blue;">MSXML6</span>"<span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">RegistrySearch </span><span style="color:red;">Id</span><span style="color:blue;">=</span>"<span style="color:blue;">MSXML6Search</span>" <span style="color:red;">Root</span><span style="color:blue;">=</span>"<span style="color:blue;">HKCR</span>" <span style="color:red;">Key</span><span style="color:blue;">=</span>"<span style="color:blue;">Msxml2.DOMDocument.6.0</span>" <span style="color:red;">Type</span><span style="color:blue;">=</span>"<span style="color:blue;">raw</span>" <span style="color:blue;">/
&lt;/</span><span style="color:#a31515;">Property</span><span style="color:blue;">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>This code is very standard code for polling a registry value – no surprises here.  The next step is to build in two custom actions that both tie to this property:</p>
<pre class="code"><span style="color:blue;">&lt;</span><span style="color:#a31515;">Property </span><span style="color:red;">Id</span><span style="color:blue;">=</span>"<span style="color:blue;">cmd</span>" <span style="color:red;">Value</span><span style="color:blue;">=</span>"<span style="color:blue;">cmd.exe</span>" <span style="color:blue;">/&gt;
&lt;</span><span style="color:#a31515;">CustomAction </span><span style="color:red;">Id</span><span style="color:blue;">=</span>"<span style="color:blue;">OpenMSXML6Download</span>" <span style="color:red;">Property</span><span style="color:blue;">=</span>"<span style="color:blue;">cmd</span>"
    <span style="color:red;">ExeCommand</span><span style="color:blue;">=</span>"<span style="color:blue;">/c start http://www.microsoft.com/downloads/details.aspx?FamilyID=993c0bcf-3bcf-4009-be21-27e85e1857b1</span>"
    <span style="color:red;">Execute</span><span style="color:blue;">=</span>"<span style="color:blue;">oncePerProcess</span>"
    <span style="color:red;">Return</span><span style="color:blue;">=</span>"<span style="color:blue;">check</span>" <span style="color:blue;">/&gt;
&lt;</span><span style="color:#a31515;">CustomAction </span><span style="color:red;">Id</span><span style="color:blue;">=</span>"<span style="color:blue;">OpenMSXML6DownloadError</span>" <span style="color:red;">Error</span><span style="color:blue;">=</span>"<span style="color:#0000ff;">MSXML6 must be installed first.</span>" <span style="color:blue;">/&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The first Custom Action executes a command window, and starts the URL in the ExeCommand.  The important and confusing thing to note here is that the actual command to execute is put in a property, and any parameters are put in “ExeCommand” which is very poorly named.  The parameters in this case are a trick to start up the default browser to the desired URL.  The minor drawback to this is that you see the command window briefly.  I think there is a better way to do this that I’ve seen but not yet tried that involves doing a registry search to locate the default browser executable and then calling it directly.</p>
<p>The second custom action simply opens an Error dialog and exits the installation.</p>
<p>The third piece to this puzzle is to insert the Custom Action into the InstallExecuteSequence:</p>
<pre class="code"><span style="color:blue;">&lt;</span><span style="color:#a31515;">InstallExecuteSequence</span><span style="color:blue;">&gt;
</span><span style="color:blue;">    &lt;!-- </span><span style="color:green;">Takes user to MSXML6 download page to be installed </span><span style="color:blue;">--&gt;
    &lt;</span><span style="color:#a31515;">Custom </span><span style="color:red;">Action</span><span style="color:blue;">=</span>"<span style="color:blue;">OpenMSXML6Download</span>" <span style="color:red;">After</span><span style="color:blue;">=</span>"<span style="color:blue;">AppSearch</span>"<span style="color:blue;">&gt;</span>NOT MSXML6 AND Not Installed<span style="color:blue;">&lt;/</span><span style="color:#a31515;">Custom</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">Custom </span><span style="color:red;">Action</span><span style="color:blue;">=</span>"<span style="color:blue;">OpenMSXML6DownloadError</span>" <span style="color:red;">After</span><span style="color:blue;">=</span>"<span style="color:blue;">OpenMSXML6Download</span>"<span style="color:blue;">&gt;</span>NOT MSXML6 AND Not Installed<span style="color:blue;">&lt;/</span><span style="color:#a31515;">Custom</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">InstallExecuteSequence</span><span style="color:blue;">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>One critical piece of information here is to note the “After=AppSearch”.  When I was first trying to get this to work, I dealt with an huge amount of frustration because I had set this to “After=FindRelatedProducts”.  I had chosen this because although I don’t show it above, this particular WiX install also enables the app to install over itself and prevents downgrading, and in that scenario, that’s the After value that you use.  My assumption that it would work to simulate the InstallURL was a very bad one.  The problem is that FindRelatedProducts occurs before AppSearch, which is where the RegistrySearch property is evaluated.  As a result, the MSXML6 property was NEVER defined and I was redirecting to the download page even if MSXML6 was installed.  (BTW this is a good reason to download and install the Windows SDK tools – I only discovered this because I bothered to open the MSI in Orca!)</p>
<p>With these three pieces in place, the installer now correctly detects MSXML6 and will redirect the user to the download page (and terminate) if it isn’t installed.  Note, however, that as presented above, the user may have to go thru the majority of the UI install before this happens.  If you don’t want the user to see any of the UI before the check and redirect takes place, duplicate the InstallExecuteSequence lines into the InstallUISequence section of the WXS file.  I’ve been told it’s somewhat of a bad practice, but that does fall more in line with the way the Visual Studio InstallURL works.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=150&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/10/24/simulating-vs-nets-msi-installurl-property-with-wix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/925135adb117b6fd6a194853ddd0425c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbray</media:title>
		</media:content>
	</item>
		<item>
		<title>My wife always said I can&#8217;t see 4 feet in front of me&#8230;</title>
		<link>http://cticoder.wordpress.com/2009/10/20/my-wife-always-said-i-cant-see-4-feet-in-front-of-me/</link>
		<comments>http://cticoder.wordpress.com/2009/10/20/my-wife-always-said-i-cant-see-4-feet-in-front-of-me/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 18:52:56 +0000</pubDate>
		<dc:creator>Michael Bray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2009/10/20/my-wife-always-said-i-cant-see-4-feet-in-front-of-me/</guid>
		<description><![CDATA[At home, I am NOTORIOUS for looking right at things and not seeing them.&#160; This type of conversation has been heard many times thru the years: “Honey, could you pass the sugar?”&#160; “Hmm?&#160; Where is it?”&#160; “Right in front of you, doofus.” Well this isn’t just at home – it’s here at work too.&#160; And [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=149&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At home, I am NOTORIOUS for looking right at things and not seeing them.&#160; This type of conversation has been heard many times thru the years: “Honey, could you pass the sugar?”&#160; “Hmm?&#160; Where is it?”&#160; “Right in front of you, doofus.”</p>
<p>Well this isn’t just at home – it’s here at work too.&#160; And I just found something that (I presume) has been there all the time and I just never saw it.&#160; And I love it.</p>
<p>In SQL Server Management Studio, when you execute a query and display the execution plan, that plan is often (for me anyway) way larger than the screen.&#160; Sure you can right-click and there are various zoom options like ‘Zoom to fit’.&#160; But if you do that, then you are left needing jewelers glasses to see it, and worse, with having to navigate around the plan, which can be a pain.&#160; Or *was* a pain.&#160; </p>
<p>If you look closely (you might have to squint) you’ll see a + below the scroll bar:</p>
<p><a href="http://cticoder.files.wordpress.com/2009/10/image.png"><img title="image" style="display:inline;border-width:0;" height="158" alt="image" src="http://cticoder.files.wordpress.com/2009/10/image_thumb.png?w=244&#038;h=158" width="244" border="0" /></a> </p>
<p>If you click that +, you get a Panning window that lets you move anywhere in the query plan you want, pain free.&#160; And no need to zoom!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/149/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=149&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/10/20/my-wife-always-said-i-cant-see-4-feet-in-front-of-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/925135adb117b6fd6a194853ddd0425c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbray</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/10/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Enabling Automatic NTLM Authentication in Firefox</title>
		<link>http://cticoder.wordpress.com/2009/10/02/enabling-automatic-ntlm-authentication-in-firefox/</link>
		<comments>http://cticoder.wordpress.com/2009/10/02/enabling-automatic-ntlm-authentication-in-firefox/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 16:46:59 +0000</pubDate>
		<dc:creator>Michael Bray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2009/10/02/enabling-automatic-ntlm-authentication-in-firefox/</guid>
		<description><![CDATA[When browsing using Internet Explorer to a site on an internal network that is configured with Integrated Windows Authentication, such as http://intranet, IE will automatically attempt to use your domain credentials to log in.&#160; It’s always pained me that Firefox didn’t do the same thing.&#160; I thought it had something to do with some M$ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=146&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When browsing using Internet Explorer to a site on an internal network that is configured with Integrated Windows Authentication, such as http://intranet, IE will automatically attempt to use your domain credentials to log in.&#160; It’s always pained me that Firefox didn’t do the same thing.&#160; I thought it had something to do with some M$ hocus pocus undocumented feature magic that prevented FF from being able to do this.&#160; SO wrong.&#160; It’s easy to enable Firefox to do the same:</p>
<p>To enable this feature in Firefox, go to the “about:config” url in Firefox, and then find the configuration parameters for “<strong>network.automatic-ntlm-auth.trusted-uris</strong>”, “<strong>network.negotiate-auth.delegation-uris</strong>”, and “<strong>network.negotiate-auth.trusted-uris</strong>”.&#160; In those values, put the URIs that you want Firefox to automatically pass authentication to.&#160; You can either use the http:// prefix or you can leave it off, and you can specify multiple parameters by separating them with a comma.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=146&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/10/02/enabling-automatic-ntlm-authentication-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/925135adb117b6fd6a194853ddd0425c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbray</media:title>
		</media:content>
	</item>
		<item>
		<title>Reconfiguring BTARN manually.</title>
		<link>http://cticoder.wordpress.com/2009/08/26/reconfiguring-btarn-manually/</link>
		<comments>http://cticoder.wordpress.com/2009/08/26/reconfiguring-btarn-manually/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 13:39:03 +0000</pubDate>
		<dc:creator>Shaun McDonnell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2009/08/26/reconfiguring-btarn-manually/</guid>
		<description><![CDATA[I ended up changing my network domain name infrastructure a little bit and had to modify my host-headers in IIS so that everything would work well together (BizTalk, BTARN, Sharepoint, etc).&#160; After I did this, I kept receiving the following error anytime I sent a message to BTARN: RNIFReceiverWebApplication:&#160; (404) Not Found Obviously that means [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=145&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I ended up changing my network domain name infrastructure a little bit and had to modify my host-headers in IIS so that everything would work well together (BizTalk, BTARN, Sharepoint, etc).&#160; After I did this, I kept receiving the following error anytime I sent a message to BTARN:</p>
<p><em>RNIFReceiverWebApplication:&#160; (404) Not Found</em></p>
<p>Obviously that means that the RNIFReceive.aspx was not passing the data off to the correct URL for the BTSHTTPReceive.dll.&#160; I looked everywhere to reconfigure this without having to uninstall the WebApps aspect of BTARN and I couldn’t find it.&#160; So, of course I looked in the registry and sure enough it was there:</p>
<p><a href="http://cticoder.files.wordpress.com/2009/08/image6.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://cticoder.files.wordpress.com/2009/08/image_thumb6.png?w=316&#038;h=267" width="316" height="267" /></a> </p>
<p>This is located under HKEY_LOCAL_MACHINE/Software/Wow6432Node/Microsoft/BizTalk Accelerator for RosettaNet/2009 (this is for the 64-bit version of the accelerator.&#160; </p>
<p>The keys you need to change are fairly obvious from here and you will need to perform an IIS reset afterwards to make sure the changes are propagated through the pipeline.</p>
<p>&#160;</p>
<p>-Shaun</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=145&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/08/26/reconfiguring-btarn-manually/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d2e543a5b65c844c89c93f8f1e92325?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shaun McDonnell</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/08/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>BizTalk 2009 and BTARN 3.5 on Windows Server 2008 Installation</title>
		<link>http://cticoder.wordpress.com/2009/08/20/biztalk-2009-and-btarn-3-5-on-windows-server-2008-installation/</link>
		<comments>http://cticoder.wordpress.com/2009/08/20/biztalk-2009-and-btarn-3-5-on-windows-server-2008-installation/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 20:29:58 +0000</pubDate>
		<dc:creator>Shaun McDonnell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2009/08/20/biztalk-2009-and-btarn-3-5-on-windows-server-2008-installation/</guid>
		<description><![CDATA[I had some interesting problems occur when trying to install BizTalk 2009 and BTARN (BizTalk Accelerator for Rosetta Net) on Windows Server 2008.&#160; At the end of the day the problems were trivial but kept halting my installation with errors I could not figure out. The first error occurred when I ran the BTARN configuration [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=134&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had some interesting problems occur when trying to install BizTalk 2009 and BTARN (BizTalk Accelerator for Rosetta Net) on Windows Server 2008.&#160; At the end of the day the problems were trivial but kept halting my installation with errors I could not figure out.</p>
<p>The first error occurred when I ran the BTARN configuration and looked something like:</p>
<p><a href="http://cticoder.files.wordpress.com/2009/08/image.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://cticoder.files.wordpress.com/2009/08/image_thumb.png?w=328&#038;h=146" width="328" height="146" /></a> </p>
<p>which reads:</p>
<p><em>“A BizTalk Isolated Host instance configured with the user account ‘BizTalkMumbles’ was either not running or does not exist on this computer.&#160; Use the BizTalk Administration Console to create a new Isolated host or to reconfigure an existing host to run as ‘BizTalkMumbles&#8217;”</em></p>
<p>&#160;</p>
<p>Well, I had done all of that already so this obviously wasn’t the problem.&#160; It turned out I needed to use &lt;COMPUTERNAME&gt;\BizTalkMumbles or &lt;DOMAINNAME&gt;\BizTalkMumbles when I configured my BizTalk Host Application Instances.&#160; Once I did this the error went away.&#160; </p>
<p>Here is what the configuration looked like when I was getting the error:</p>
<p><a href="http://cticoder.files.wordpress.com/2009/08/image5.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://cticoder.files.wordpress.com/2009/08/image_thumb5.png?w=1097&#038;h=86" width="1097" height="86" /></a> </p>
<p>And here is the configuration that made the error go away:</p>
<p><a href="http://cticoder.files.wordpress.com/2009/08/image2.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://cticoder.files.wordpress.com/2009/08/image_thumb2.png?w=1101&#038;h=95" width="1101" height="95" /></a> </p>
<p>Note the change in the Logon.</p>
<p>I consider this to be Microsoft’s issue as the underlying logon user never changed but adding the machine or domain name helped.</p>
<p>Then, when I proceeded into my BTARN configuration, installing the Runtime and the WebApp failed miserably with errors in the log file that looked like this:</p>
<p><em>12:50:33 PM Info ConfigHelper]&#160;&#160;&#160;&#160; Detected IIS version: 7      <br />[12:50:33 PM Error ConfigHelper] d:\depot2300\mercury\private\common\configwizard\confighelper\iis.cpp(594): FAILED hr = 80040154 </em></p>
<p><em>[12:50:33 PM Error ConfigHelper]&#160;&#160;&#160;&#160; Failed to open application pool Error: d!      <br />[12:50:33 PM Error ConfigHelper] Class not registered       <br />[12:50:33 PM Error ConfigHelper] d:\depot2300\mercury\private\common\configwizard\confighelper\iis.cpp(151): FAILED hr = 80040154 </em></p>
<p><em>[12:50:33 PM Info ConfigHelper]&#160;&#160;&#160;&#160; Error -2147221164 occurred while attempting to retrieve site ID for site      <br />[12:50:33 PM Error ConfigHelper] Class not registered       <br />[12:50:33 PM Error RNConfig] c:\depot\europa2009\private\europa_source\btarnconfig\dll\rnconfig.cpp(2211): FAILED hr = 80040154 </em></p>
<p><em>[12:50:33 PM Info RNConfig] Leaving function: CRNConfig::ConfigureFeature      <br />[12:50:33 PM Warning Configuration Framework]Feature failed to configure: WebApps.       <br />[12:50:33 PM Info Configuration Framework]Configuration Summaries:       <br />[12:50:33 PM Error Configuration Framework]Feature: [Runtime] Failed to configure with error message [&lt;Exception Message=&quot;Class not registered&quot; Source=&quot;ConfigHelper&quot; HelpID=&quot;HelpIdGetWebsiteID&quot;/&gt;]       <br />[12:50:33 PM Error Configuration Framework]Feature: [WebApps] Failed to configure with error message [&lt;Exception Message=&quot;Class not registered&quot; Source=&quot;ConfigHelper&quot; HelpID=&quot;HelpIdGetWebsiteID&quot;/&gt;]       <br />[12:50:33 PM Info Configuration Framework]&#160;&#160;&#160; Feature: Runtime&#160;&#160;&#160; Configuration Enabled: yes&#160;&#160;&#160; Sub UI: no&#160;&#160;&#160; Configured: no       <br />[12:50:33 PM Info Configuration Framework]&#160;&#160;&#160; Feature: WebApps&#160;&#160;&#160; Configuration Enabled: yes&#160;&#160;&#160; Sub UI: no&#160;&#160;&#160; Configured: no</em></p>
<p>&#8212;</p>
<p>I figured BTARN was having trouble talking to IIS and maybe needed IIS6 Compatability installed to be able to make the connection.&#160; That turned out to be the case:</p>
<p><a href="http://cticoder.files.wordpress.com/2009/08/image3.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://cticoder.files.wordpress.com/2009/08/image_thumb3.png?w=529&#038;h=256" width="529" height="256" /></a> </p>
<p>Make sure you have the ‘IIS 6 Management Compatability’ Role Service installed for IIS 7.</p>
<p>I searched and searched the net for answers on this and never found anything so I figured I would post my findings here.</p>
<p>-Shaun</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=134&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/08/20/biztalk-2009-and-btarn-3-5-on-windows-server-2008-installation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d2e543a5b65c844c89c93f8f1e92325?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shaun McDonnell</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/08/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/08/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/08/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/08/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>A mathematical diversion with LINQ</title>
		<link>http://cticoder.wordpress.com/2009/07/18/a-mathematical-diversion-with-linq/</link>
		<comments>http://cticoder.wordpress.com/2009/07/18/a-mathematical-diversion-with-linq/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 06:43:29 +0000</pubDate>
		<dc:creator>Michael Bray</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/?p=120</guid>
		<description><![CDATA[Every now and then I’ll come across a math problem as part of my work…   It’s not what I do it’s just something that happens.  When it does happen, I either become obsessed with it until I solve it (or at least THINK I solve it, one way or another) or I eventually give up [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=120&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Every now and then I’ll come across a math problem as part of my work…   It’s not what I do it’s just something that happens.  When it does happen, I either become obsessed with it until I solve it (or at least THINK I solve it, one way or another) or I eventually give up with the blunt realization that I just spent hours thinking about something that is likely to cause psychosis in old age.  Fortunately, the problem I ran across today seems to have fallen into the first category… </p>
<p>Here’s the question, simplified…   Imagine you have a collection of at least 10 items, of which you are going to choose 5 at random.  One of those 5 is then taken away and replaced with a different NEW item (pulled from some other pile of items).  Next you choose another 5, again randomly.  The questions I asked myself in this scenario were:</p>
<ol>
<li>What are the chances that you WON’T see any of the same 5 that you originally picked? </li>
<li>What if the collection is 20 items instead of 10 items? </li>
<li>How many items have to be in the larger collection so that you have at least a 90% chance of NOT seeing any one of the originally chosen items if you are choosing 5 at a time?</li>
</ol>
<h5>The Math…</h5>
<p>This actually is a fairly simple problem to solve…  but I ran thru an interesting programming journey on the way to the answers, and it was the programming aspect that prompted this post.  To reiterate the scenario, the collection starts with 10 items of which 5 are chosen and one is taken away; then another NEW item is added, again giving you 10 items from which to choose 5 of them, and out of the 10 from which you choose, 4 of them were ones you saw before. </p>
<p>When working problems of this kind (because I’m not so good at probabilities) I prefer to back up to a simpler case.  So let’s consider what happens when you have 6 items in the collection, and you choose 3 at a time.  This means that on the second draw, there will be 2 that must be avoided.  If the items in the second draw are A, B, C, D, E, and F, and we presume that E and F must be avoided, then we have the following:</p>
<ul>
<li>“Good” choices: ABC, ABD, ACD, BCD</li>
<li>“Bad” choices: ABE, ABF, ACE, ACF, ADE, ADF, AEF, BCE, BCF, BDE, BDF, BEF, CDE, CDF, CEF, DEF</li>
</ul>
<p>So there are 20 possible choices, of which only 4 yield a good result.  Each of these numbers is a <a href="http://en.wikipedia.org/wiki/Binomial_coefficient">binomial coefficient</a>.  The number 20 is the total number of 3-letter combinations, or <sub>6</sub>C<sub>3</sub>. The number 4 is the number of 3-letter combinations of only the first 4 “good” letters, or <sub>4</sub>C<sub>3</sub>. So it should be clear that in general, the number of total choices is <sub>N</sub>C<sub>r</sub> where <em>N</em> is the number of items in the collection, <em>r</em> is the number of items we are picking, and the number of &#8220;good&#8221; choices is <sub>M</sub>C<sub>r</sub> where <em>M</em> = <em>N</em> &#8211; <em>r</em> + 1.</p>
<p>So now the answer to the first question becomes easy…  If you only have 10 items to choose from at a time, this means that 5 were chosen from the original 10, and then one of those 5 goes away and will be replaced by a new (unseen) item, so there are 4 out of 10 that need to be avoided.  Thus in this case, N=10, r=5, and M=6.  And thus, the likelihood that you WON’T see any of the original 5 (but really 4) items is:</p>
<p><img style="display:inline;border-width:0;" title="eqn7566" src="http://cticoder.files.wordpress.com/2009/07/eqn7566.png?w=248&#038;h=67" border="0" alt="eqn7566" width="248" height="67" />    <!-- \frac{{}_{6}C_{5}}{{}_{10}C_{5}} = \frac{6}{252}= \frac{1}{42} --></p>
<p>Wow… <a href="http://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy">the answer really is 42</a>!!!  (Sort of.)</p>
<p>Ok, so what about the second question…   well the answer is still easy, because it is the same formula…  except now the numbers get bigger…   N=20, r=5, M=16:</p>
<p><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="eqn7566" src="http://cticoder.files.wordpress.com/2009/07/eqn75661.png?w=228&#038;h=67" border="0" alt="eqn7566" width="228" height="67" /> <!-- \frac{{}_{16}C_{5}}{{}_{20}C_{5}} = \frac{4368}{15504} = 28.17\% --></p>
<p>Ok so what about the third problem?  Well it’s just a matter of plugging numbers in, but calculating binomial coefficients over and over for such large numbers really gets tiring…  and besides, like any good programmer, I wanted confirmation that I was doing my math right…   And that’s where we move to the fun part of this story.</p>
<h5>Where’s the LINQ?</h5>
<p>Ok so at this point I have two of the three answers, but I wanted to make sure I wasn’t screwing up the “easy” part.  I figured that this type of problem isn’t exactly custom-tailored for a LINQ query, but I figured I could have some fun and learn a bit more about Linq by using “<span style="font-size:x-small;"><span style="font-family:Courier New;"><span style="color:#2b91af;">Enumerable</span>.Range”</span></span> and some Linq extension methods.  So it’s just a matter of getting the code working…    But one thing that I really hate is using Visual Studio to create some dinky little project to do this sort of stuff – I’d much prefer a “snippet compiler” that will let me just type a bit of code and run it.  There are some programs around that do this, such as…  (wait for it…) <a href="http://www.sliver.com/dotnet/SnippetCompiler/">SnippetCompiler</a>.  It is a neat program because it basically let you write fully functional program without having to open VS.net.  But I found it’s IntelliSense somehow clunky and something about it always made me not like it too much, but it was still better than the alternative.  However, recently I have found a FANTASTIC application called <a href="http://www.linqpad.net/">LinqPad</a>.  LinqPad can also compile snippets, but it is much more than just that…  It can dynamically evaluate LINQ expressions (or entire .NET programs), translate between LINQ syntax and <a href="http://msdn.microsoft.com/en-us/library/bb397687.aspx">lambda syntax</a>, show you the generated IL, and can access databases on the fly so you are working with real data.  The author even touts it as a replacement for SSMS, and it certainly could, but I think that’s going a bit far since the results display isn’t quite tailored to that type of data, and I don’t think you can edit data in place (but I might be wrong).  It includes a lot of examples and apparently you can download more.  BUT… one of the <strong><em>really</em></strong> nice things is that it can compile and execute single statements – they don’t even have to be full programs as they do in SnippetCompiler.  For example, you can just type in “<span style="color:#2b91af;">Enumerable</span>.Range(10,10).ToList().ConvertAll(x =&gt; <span style="color:blue;">new </span>{ X=x, XSquared = x*x })” and here’s what you get out:</p>
<p><a href="http://cticoder.files.wordpress.com/2009/07/image.png"><img style="display:inline;border-width:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb.png?w=114&#038;h=244" border="0" alt="image" width="114" height="244" /></a></p>
<p>Amazing!  And trust me… that’s only the tip of the iceberg.  (Note that the shaded line is a “total sum” of the column – I don’t know why they do that, but I don’t see a way to turn it off.)  LinqPad also provides IntelliSense, although that is a feature you have to purchase.</p>
<h5>Now comes the crazy part…</h5>
<p>OK so I now started writing up some some LINQ and I quickly realized that there was no <a href="http://en.wikipedia.org/wiki/Factorial">Factorial</a> function in Math or any of the other standard libraries, and there was no way I was getting by without it.  So my first hunt was to find a Factorial function.  Not just any factorial function, but one written in LINQ, of course.  (Note that this was only because I was having fun; LinqPad is fully capable of compiling and executing non-LINQ C# code, so I could have just written a function to do it.)  My hunt took an odd turn, though, because it seems that writing a recursive function in Linq isn’t as easy as it is in good old fashioned code.  But with the magic and a bit of wizardry, it can be done.  I won’t try to explain it (because I don’t even come close to understanding it) but you can find the solution <a href="http://www.pluralsight.com/community/blogs/jeffsch/archive/2006/08/18/33631.aspx">here</a>.  They use something called a “YCombinator” to do it, but to keep things simple and clear, here is just the lambda that results from its use:</p>
<pre class="code"><span style="color:#2b91af;">Func</span>&lt;<span style="color:#2b91af;">int</span>, <span style="color:#2b91af;">int</span>&gt; factorial = <span style="color:#2b91af;">Extensions</span>.YCombinator&lt;<span style="color:#2b91af;">int</span>, <span style="color:#2b91af;">int</span>&gt;(fact =&gt; n =&gt; n &lt; 2 ? 1 : n * fact(n - 1));</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And a quick test of this shows that it works:</p>
<blockquote>
<pre class="code"><span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(1,10).ToList().ConvertAll(x =&gt; <span style="color:blue;">new </span>{ x = x, factorial = factorial(x) });</pre>
<p><a href="http://cticoder.files.wordpress.com/2009/07/image1.png"><img style="display:inline;border-width:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb1.png?w=114&#038;h=244" border="0" alt="image" width="114" height="244" /></a></p></blockquote>
<p>Ok so now instead of building up a whole lot of factorial expressions, I’ll also define a lambda that handles the Combination function, like so:</p>
<pre class="code"><span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">int</span>, <span style="color:blue;">int</span>, <span style="color:blue;">int</span>&gt; C = (n, r) =&gt; factorial(n) / factorial(r) / factorial(n - r);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<blockquote>
<pre class="code"><span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(3,10).ToList().ConvertAll(x =&gt; <span style="color:blue;">new </span>{ x = x, factorial = factorial(x), nC3 = C(x, 3) });</pre>
<pre class="code"><a href="http://cticoder.files.wordpress.com/2009/07/image2.png"><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb2.png?w=154&#038;h=244" border="0" alt="image" width="154" height="244" /></a></pre>
<p><a href="http://11011.net/software/vspaste"></a></p></blockquote>
<p><a href="http://1.bp.blogspot.com/_jHtjtOoogw0/SbHgfIqhRMI/AAAAAAAAAKQ/ApsiqNrQOrs/s1600-h/coolio_large.jpg">Coolio</a>!!!  Alright now we are talking, because now I can verify my answers.  In order to do this, I’ll just calculate each of the values from N=10 to N=20 (why not!), along with the corresponding percentage calculation:</p>
<blockquote>
<pre class="code"><span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(10,10).ToList();
<span style="color:blue;">int </span>r = 5;
<span style="color:blue;">var </span>y = N.ConvertAll(x =&gt; <span style="color:blue;">new </span>{
    M = x-r+1,
    mCr = C(x-r+1, r),
    N = x,
    nCr = C(x, r),
    Frac = ((<span style="color:blue;">decimal</span>)C(x-r+1, r) / C(x, r)).ToString(<span style="color:#a31515;">"P2"</span>)
    });</pre>
<pre class="code"><a href="http://cticoder.files.wordpress.com/2009/07/image3.png"><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb3.png?w=177&#038;h=48" border="0" alt="image" width="177" height="48" /></a></pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p>Oops!!  Divide by zero???  How in the heck could that happen??  So I commented out the only place there could be a divide by zero, the Frac calculation:</p>
<blockquote>
<pre class="code"><span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(10,11).ToList();
<span style="color:blue;">int </span>r = 5;
<span style="color:blue;">var </span>y = N.ConvertAll(x =&gt; <span style="color:blue;">new </span>{
    M = x-r+1,
    mCr = C(x-r+1, r),
    N = x,
    nCr = C(x, r),
    <span style="color:green;">//Frac = ((decimal)C(x-r+1, r) / C(x, r)).ToString("P2")
    </span>});</pre>
<pre class="code"><a href="http://cticoder.files.wordpress.com/2009/07/image4.png"><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb4.png?w=150&#038;h=244" border="0" alt="image" width="150" height="244" /></a></pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Sure enough – there’s the zeros…   but WHY – there’s no way that a binomial coefficient can produce zero!  …And the first several answers are all correct.  Then I realized that the problem you always have when dealing with Factorials – the numbers get big really fast.  Maybe <span style="color:blue;">int</span> wasn’t the best choice…  so I switched to long:</p>
<blockquote>
<pre class="code"><span style="color:blue;">static </span><span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">long</span>, <span style="color:blue;">long</span>&gt; factorial = <span style="color:#2b91af;">Extensions</span>.YCombinator&lt;<span style="color:blue;">long</span>, <span style="color:blue;">long</span>&gt;(fact =&gt; n =&gt; n &lt; 2 ? 1 : n * fact(n - 1));
<span style="color:blue;">static </span><span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">long</span>, <span style="color:blue;">long</span>, <span style="color:blue;">long</span>&gt; C = (n, r) =&gt; factorial(n) / factorial(r) / factorial(n - r);
<span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(10,11).ToList();
<span style="color:blue;">int </span>r = 5;
<span style="color:blue;">var </span>y = N.ConvertAll(x =&gt; <span style="color:blue;">new </span>{
    M = x-r+1,
    mCr = C(x-r+1, r),
    N = x,
    nCr = C(x, r),
    Frac = ((<span style="color:blue;">decimal</span>)C(x-r+1, r) / C(x, r)).ToString(<span style="color:#a31515;">"P2"</span>)
    });</pre>
<pre class="code"><a href="http://cticoder.files.wordpress.com/2009/07/image5.png"><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb5.png?w=201&#038;h=244" border="0" alt="image" width="201" height="244" /></a></pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Now that is more like it…  and so now I had the answers to TWO of the questions…   With 10 in the collection and choosing 5 at a time, you have only a 2.38% chance of not seeing one of the original items, and with 20 items you have a 28.17% chance of not seeing one of the original items.  So what would it take to get a 90% chance of not seeing one of the original items?  OK no big deal, I’ll just keep going…  Uhhhh…  wait a minute.  The <span style="color:blue;">long</span> type ALSO has a maximum value…   I wondered how “long” would it be before I started getting mangled numbers?   Not very long it turns out.  In fact, the calculation goes bonkers on the very next value of N, N=21:</p>
<blockquote>
<pre class="code"><span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(20,2).ToList();</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://cticoder.files.wordpress.com/2009/07/image6.png"><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb6.png?w=241&#038;h=102" border="0" alt="image" width="241" height="102" /></a></p></blockquote>
<p>So now what?  Double??  At first it appeared that it would work…   but RIGHT BEFORE I got to my answer of 90%, <a href="http://www.directcreative.com/blog/kaboom-the-selling-magic-of-billy-mays">KABOOM</a>! </p>
<blockquote>
<pre class="code"><span style="color:blue;">static </span><span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">double</span>, <span style="color:blue;">double</span>&gt; factorial = <span style="color:#2b91af;">Extensions</span>.YCombinator&lt;<span style="color:blue;">double</span>, <span style="color:blue;">double</span>&gt;(fact =&gt; n =&gt; n &lt; 2 ? 1 : n * fact(n - 1));
<span style="color:blue;">static </span><span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">double</span>, <span style="color:blue;">double</span>, <span style="color:blue;">double</span>&gt; C = (n, r) =&gt; factorial(n) / factorial(r) / factorial(n - r);
<span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(160,14).ToList();
<span style="color:blue;">int </span>r = 5;
<span style="color:blue;">var </span>y = N.ConvertAll(x =&gt; <span style="color:blue;">new </span>{
    M = x-r+1,
    mCr = C(x-r+1, r),
    N = x,
    nCr = C(x, r),
    Frac = ((<span style="color:blue;">double</span>)C(x-r+1, r) / C(x, r)).ToString(<span style="color:#a31515;">"P2"</span>)
    });</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://cticoder.files.wordpress.com/2009/07/image7.png"><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb7.png?w=244&#038;h=241" border="0" alt="image" width="244" height="241" /></a></p></blockquote>
<p>At this point, I want you to take notice of the fact that I’m already up to 160+ items in the collection…  even with this many, when choosing 5, and replacing 1 of those 5 with a new item, and then picking 5 more from the full collection, you still don’t quite have a 90% chance of NOT seeing one of the original 5.  REALLY?!?!  <strong><em>Out of 160+ items I’m only picking 5, trying to avoid 4 of them, and I don’t have a 90% chance of doing that!?!?!</em></strong>  No wonder I always lost at <a href="http://www.miniclip.com/games/battleships/en/">Battleship</a>.  I could pick 5 items from the collection 10 times over and still not have picked one-third of the available items…   odd… but ok, I trust the math.</p>
<p>Anyway…  Still without an answer to the question, and coming SO close, I couldn’t drop it now.  So what is out there that’s larger than a double and will operate on my measly 32 bit machine?  Ahhh yes…  BigInt!  So that started my quest for a BigInt class for C#, and I was surprised how hard it was to find one.  Apparently, there used to be a BigInt included in the System.Core library in the pre-release versions of .NET 3.5, but it was taken out before the official release.  Too bad – that would have been the easiest way to go.  I did eventually find a C# BigInt <a href="http://www.codeproject.com/KB/cs/BigInt.aspx">here</a>.</p>
<p>So now I plugged in my BigInt, and after a few tweaks to handle the implementation of the BigInt class and some tweaks for efficiency and display, I arrived at my answer:</p>
<blockquote>
<pre class="code"><span style="color:blue;">var </span>N = <span style="color:#2b91af;">Enumerable</span>.Range(190,11).ToList();
<span style="color:blue;">int </span>r = 5;
<span style="color:blue;">var </span>y = N.ConvertAll(x =&gt; <span style="color:blue;">new </span>{
    M = x-r+1,
    mCr = C(x-r+1, r),
    N = x,
    nCr = C(x, r)
    });
<span style="color:blue;">var </span>z = y.ConvertAll(yy =&gt; <span style="color:blue;">new </span>{
    M = yy.M,
    mCr = yy.mCr.ToString(),
    N = yy.N,
    nCr = yy.nCr.ToString(),
    Frac = (<span style="color:blue;">double</span>.Parse(yy.mCr.ToString()) / <span style="color:blue;">double</span>.Parse(yy.nCr.ToString())).ToString(<span style="color:#a31515;">"P2"</span>)
    });</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://cticoder.files.wordpress.com/2009/07/image8.png"><img style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" title="image" src="http://cticoder.files.wordpress.com/2009/07/image_thumb8.png?w=244&#038;h=208" border="0" alt="image" width="244" height="208" /></a></p></blockquote>
<p>Thus…   <a href="http://www.imdb.com/title/tt0343818/">I calculate</a> that you would need a collection of 194 items from which to pull 5 items in order to have a &gt;90% chance that you wouldn’t see one of the original 5 (really 4, since one is taken away).  That seems totally counter-intuitive to me, but this apparently a good example of diminishing returns! </p>
<p>My next quest…   to find Factorial/Combination classes (probably utilizing BigInt) that can efficiently handle the fact that calculations of this kind, although they involve HUGE numbers if you work them out directly as I have here, actually represent relatively small numbers since factors often cancel out and I probably could have calculated the answer as fast on paper faster as it took me to write the code (assming I knew what the answer was!).  The above query didn’t take that long to run on my machine (almost 25 seconds) but it took me a while to figure out where the right value was.  The point is, with specially coded Factorial and Combination classes, I think this could be much faster and much more efficient.</p>
<p>Finally, along the course of this, I also found a nice <a href="http://rogercortesi.com/eqn/index.php">LaTeX Equation Image Genarator</a> on the web that I used for the math images… actually I found 3 or 4, but this was the only one that seemed to be working, so thanks to Roger!</p>
<p><em> </em></p>
<p>~ Michael D. Bray</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/120/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=120&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/07/18/a-mathematical-diversion-with-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/925135adb117b6fd6a194853ddd0425c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbray</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/eqn7566.png" medium="image">
			<media:title type="html">eqn7566</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/eqn75661.png" medium="image">
			<media:title type="html">eqn7566</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://cticoder.files.wordpress.com/2009/07/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows 7 Slow.  Constant Hard Drive Activity.</title>
		<link>http://cticoder.wordpress.com/2009/05/06/windows-7-slow-constant-hard-drive-activity/</link>
		<comments>http://cticoder.wordpress.com/2009/05/06/windows-7-slow-constant-hard-drive-activity/#comments</comments>
		<pubDate>Wed, 06 May 2009 01:09:25 +0000</pubDate>
		<dc:creator>Shaun McDonnell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cticoder.wordpress.com/2009/05/06/windows-7-slow-constant-hard-drive-activity/</guid>
		<description><![CDATA[This one had me stumped for about an hour today.&#160; I have been running Microsoft Windows Vista Ultimate 64-bit for a couple years now on my Dell Precision with 0 problems.&#160; So, naturally I decided it was time to upgrade to Windows 7 Ultimate. Much to my dismay, after performing a fresh installation of Windows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=93&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This one had me stumped for about an hour today.&#160; </p>
<p>I have been running Microsoft Windows Vista Ultimate 64-bit for a couple years now on my Dell Precision with 0 problems.&#160; So, naturally I decided it was time to upgrade to Windows 7 Ultimate.</p>
<p>Much to my dismay, after performing a fresh installation of Windows 7 Ultimate 64-bit Edition I found that it was acting very strange.&#160; Sometimes it would sit for a few seconds when I did simple things like close a window or open the Start Menu.&#160; It was very slow.&#160; Furthermore, the hard drive light was always on and the hard drive was always making sounds.</p>
<p>I knew this had to be a driver issue because the machine had worked flawlessly under the heavy pressures of Vista.&#160; So I started by flashing the BIOS.&#160; That didn’t work.&#160; I tried updating my display drivers and that did nothing.</p>
<p>I decided to see if I needed to update the Intel Chipset driver and it turns out that solved everything.&#160; Microsoft has done a good job of making sure Windows 7 gets all of the correct drivers during installation as all of my other machines have worked flawlessly.</p>
<p>Unfortunately, Intel doesn’t have any Windows 7 x64 specific drivers:</p>
<p><a title="http://downloadcenter.intel.com/filter_results.aspx?strTypes=all&amp;ProductID=2261&amp;OSFullName=Windows+Vista*+64&amp;lang=eng&amp;strOSs=150&amp;submit=Go%21" href="http://downloadcenter.intel.com/filter_results.aspx?strTypes=all&amp;ProductID=2261&amp;OSFullName=Windows+Vista*+64&amp;lang=eng&amp;strOSs=150&amp;submit=Go%21">http://downloadcenter.intel.com/filter_results.aspx?strTypes=all&amp;ProductID=2261&amp;OSFullName=Windows+Vista*+64&amp;lang=eng&amp;strOSs=150&amp;submit=Go%21</a></p>
<p>However, using the Vista x64 drivers did the trick and everything works great now.</p>
<p>&#160;</p>
<p>-Shaun</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cticoder.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cticoder.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cticoder.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cticoder.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cticoder.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cticoder.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cticoder.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cticoder.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cticoder.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cticoder.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cticoder.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cticoder.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cticoder.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cticoder.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cticoder.wordpress.com&amp;blog=2318044&amp;post=93&amp;subd=cticoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cticoder.wordpress.com/2009/05/06/windows-7-slow-constant-hard-drive-activity/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d2e543a5b65c844c89c93f8f1e92325?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shaun McDonnell</media:title>
		</media:content>
	</item>
	</channel>
</rss>
