<?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>The Persistent Weblog</title>
	<atom:link href="http://phejndorf.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://phejndorf.wordpress.com</link>
	<description>- stuff that Per Hejndorf stumbled upon along the way</description>
	<lastBuildDate>Mon, 16 Jan 2012 16:09:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='phejndorf.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Persistent Weblog</title>
		<link>http://phejndorf.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://phejndorf.wordpress.com/osd.xml" title="The Persistent Weblog" />
	<atom:link rel='hub' href='http://phejndorf.wordpress.com/?pushpress=hub'/>
		<item>
		<title>RazorEngine, Templating Anywhere.</title>
		<link>http://phejndorf.wordpress.com/2012/01/16/razorengine-templating-anywhere/</link>
		<comments>http://phejndorf.wordpress.com/2012/01/16/razorengine-templating-anywhere/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 15:48:28 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/?p=284</guid>
		<description><![CDATA[For the last couple of months I have been deep into building mobile WebApps with jQuery Mobile and MVC 4. I must say that working with MVC, as an old ASP hack, has been a very pleasant experience and change from WebForms. MVC really joins the flexibility and transparency of a scripted language, be it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=284&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For the last couple of months I have been deep into building mobile WebApps with jQuery Mobile and MVC 4. I must say that working with MVC, as an old ASP hack, has been a very pleasant experience and change from WebForms. MVC really joins the flexibility and transparency of a scripted language, be it ASP or PHP, with a modern structured approach (maintainability, testability, readability etc).</p>
<p>Working with the View-engine you quickly get the feeling that this could be used for other things, such as generating stuff like SQL, MDX, HTML output for PDF conversion or other report generators. </p>
<p>Enter the <a href="http://razorengine.codeplex.com/">CodePlex RazorEngine</a> project, available right inside VS2010 via NuGet, which builds on MVC to deliver the same features for other .Net environments. Other people, like <a href="http://www.west-wind.com/weblog/posts/2010/Dec/27/Hosting-the-Razor-Engine-for-Templating-in-NonWeb-Applications">Rick Strahl</a>, have made similar efforts to harness the power of Razor. This guy on <a href="http://www.codeproject.com/KB/TipsnTricks/DynamicCSSRazorEngine.aspx">CodeProject</a> uses RazorEngine for CSS generation.</p>
<p>Having played with it for a couple of hours I discovered that the documentation and samples aren’t completely up to date, so here is my very simple code sample. I’m sure there’s a lot more to it, but this at least got me started:</p>
<pre class="code"><span style="color:blue;">using </span>System;
<span style="color:blue;">using </span>RazorEngine;
<span style="color:blue;">using </span>System.Dynamic;

<span style="color:blue;">namespace </span>BatchRazor
{
    <span style="color:blue;">public class </span><span style="color:#2b91af;">Test
    </span>{
        <span style="color:blue;">public string </span>Name { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }
    }

    <span style="color:blue;">class </span><span style="color:#2b91af;">Program
    </span>{
        <span style="color:blue;">public static void </span>Main(<span style="color:blue;">string</span>[] args)
        {
            <span style="color:blue;">string </span>template =
                <span style="color:#a31515;">&quot;@{var _v = \&quot;Mr \&quot; + Model.Name; }&quot; </span>+
                <span style="color:#a31515;">&quot;Hello @_v, Welcome to Razor at @DateTime.Now.ToString()!&quot;</span>;

            <span style="color:green;">// Anonymous

            </span><span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#2b91af;">Razor</span>.Parse(template, <span style="color:blue;">new </span>{ Name = <span style="color:#a31515;">&quot;World&quot; </span>}));

            <span style="color:green;">// Dynamic

            </span><span style="color:blue;">dynamic </span>d = <span style="color:blue;">new </span><span style="color:#2b91af;">ExpandoObject</span>();
            d.Name = <span style="color:#a31515;">&quot;Expando1&quot;</span>;

            <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#2b91af;">Razor</span>.Parse(template, d));

            <span style="color:#2b91af;">Razor</span>.Compile(template, <span style="color:blue;">typeof</span>(<span style="color:#2b91af;">ExpandoObject</span>), <span style="color:#a31515;">&quot;complex&quot;</span>);
            <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#2b91af;">Razor</span>.Run(<span style="color:#a31515;">&quot;complex&quot;</span>, d));

            <span style="color:blue;">dynamic </span>e = <span style="color:blue;">new </span><span style="color:#2b91af;">ExpandoObject</span>();
            e.Name = <span style="color:#a31515;">&quot;Expando2&quot;</span>;
            <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#2b91af;">Razor</span>.Run(<span style="color:#a31515;">&quot;complex&quot;</span>, e));

            <span style="color:green;">// Strongly typed

            </span><span style="color:blue;">var </span>t = <span style="color:blue;">new </span><span style="color:#2b91af;">Test</span>() { Name = <span style="color:#a31515;">&quot;Test&quot; </span>};
            <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#2b91af;">Razor</span>.Parse(template, t));

            <span style="color:#2b91af;">Razor</span>.Compile(template, <span style="color:blue;">typeof</span>(<span style="color:#2b91af;">Test</span>), <span style="color:#a31515;">&quot;complex1&quot;</span>);
            t.Name = <span style="color:#a31515;">&quot;Test2&quot;</span>;
            <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#2b91af;">Razor</span>.Run(<span style="color:#a31515;">&quot;complex1&quot;</span>, t));

            <span style="color:#2b91af;">Console</span>.ReadLine();
        }
    }
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=284&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2012/01/16/razorengine-templating-anywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>
	</item>
		<item>
		<title>Using ExpandoObject (Dynamic) with XML data</title>
		<link>http://phejndorf.wordpress.com/2011/11/20/using-expandoobject-dynamic-with-xml-data/</link>
		<comments>http://phejndorf.wordpress.com/2011/11/20/using-expandoobject-dynamic-with-xml-data/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 23:16:34 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/?p=279</guid>
		<description><![CDATA[Having played with the ExpandoObject as a container for SQL data in a previous post, I’ve been playing a bit with using it for XML data which can be even more dynamic in nature. Without further ado, here is a method that will do exactly that: public static IEnumerable&#60;dynamic&#62; GetExpandoFromXml(string file, string descendantid) { var [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=279&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Having played with the ExpandoObject as a container for SQL data in <a href="http://phejndorf.wordpress.com/2011/10/30/using-c-dynamic-with-sqldatareader/" target="_blank">a previous post</a>, I’ve been playing a bit with using it for XML data which can be even more dynamic in nature.</p>
<p>Without further ado, here is a method that will do exactly that:</p>
<pre style="width:673px;height:411px;" class="code">

<span style="color:blue;">public static </span><span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:blue;">dynamic</span>&gt; GetExpandoFromXml(<span style="color:blue;">string </span>file, <span style="color:blue;">string </span>descendantid)
{
    <span style="color:blue;">var </span>expandoFromXml = <span style="color:blue;">new </span><span style="color:#2b91af;">List</span>&lt;<span style="color:blue;">dynamic</span>&gt;();

    <span style="color:blue;">var </span>doc = <span style="color:#2b91af;">XDocument</span>.Load(file);
    <span style="color:blue;">var </span>nodes = doc.Root.Descendants(descendantid);

    <span style="color:blue;">foreach </span>(<span style="color:blue;">var </span>element <span style="color:blue;">in </span>doc.Root.Descendants(descendantid))
    {
        <span style="color:blue;">dynamic </span>expandoObject = <span style="color:blue;">new </span><span style="color:#2b91af;">ExpandoObject</span>();
        <span style="color:blue;">var </span>dictionary = expandoObject <span style="color:blue;">as </span><span style="color:#2b91af;">IDictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt;;
        <span style="color:blue;">foreach </span>(<span style="color:blue;">var </span>child <span style="color:blue;">in </span>element.Descendants())
        {
            <span style="color:blue;">if </span>(child.Name.Namespace == <span style="color:#a31515;">&quot;&quot;</span>)
                dictionary[child.Name.ToString()] = child.Value.Trim();
        }
        <span style="color:blue;">yield return </span>expandoObject;
    }
}
</pre>
<p>&#160;</p>
<p>Note that I use a descendantid parameter to specify what part of my XML I want to fetch as dynamic objects.</p>
<p>In my example I was working with an RSS feed, and this is the reason why I ignore the elements that have an empty namespace, and BTW the file parameter can be an URL as well as you can see in the sample.</p>
<p>As I sample, I can get the “item” elements from the RSS feed of this blog like so:</p>
<pre class="code"><span style="color:blue;">var </span>expandolist = GetExpandoFromXml(<span style="color:#a31515;">&quot;http://phejndorf.wordpress.com/feed/&quot;</span>, <span style="color:#a31515;">&quot;item&quot;</span>);

expandolist.ToList().ForEach(element =&gt; <span style="color:#2b91af;">Console</span>.WriteLine(element.title));</pre>
<p>&#160;</p>
<p>Or perhaps, a bit more exotically, to list all the properties of each dynamic element:</p>
<pre class="code">expandolist.ToList().ForEach(element =&gt;
{
    <span style="color:blue;">var </span>dictionary = element <span style="color:blue;">as </span><span style="color:#2b91af;">IDictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt;;
    dictionary.ToList().ForEach(d =&gt; <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">&quot;{0}: {1}&quot;</span>,d.Key,d.Value));
});</pre>
<p>And that’s all there is to it! </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/279/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=279&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/11/20/using-expandoobject-dynamic-with-xml-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>
	</item>
		<item>
		<title>Microsoft Mathematics &#8211; An Amazing Freebie</title>
		<link>http://phejndorf.wordpress.com/2011/10/30/microsoft-mathematics-an-amazing-freebie/</link>
		<comments>http://phejndorf.wordpress.com/2011/10/30/microsoft-mathematics-an-amazing-freebie/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 17:21:21 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/10/30/microsoft-mathematics-an-amazing-freebie/</guid>
		<description><![CDATA[I know some people want to spell Microsoft with a $ instead of the s, and certainly some of their products are not cheap. But today my daughter (who is a 14 year old 8th grader) pointed me to Microsoft Mathematics 4.0, a fantastic free program that does math, plots etc etc. To think that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=276&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I know some people want to spell Microsoft with a $ instead of the s, and certainly some of their products are not cheap. But today my daughter (who is a 14 year old 8th grader) pointed me to <a href="http://www.microsoft.com/download/en/details.aspx?id=15702" target="_blank">Microsoft Mathematics 4.0</a>, a fantastic free program that does math, plots etc etc.</p>
<p>To think that for little more than 350 USD you can get a small PC that will run this beauty and more – back in its day the <a href="http://www.ti59.com/" target="_blank">Texas Instruments TI-59</a> was 300 USD!</p>
<p>The Microsoft Mathematics even features a Word plugin, that will actually let you do part of your Math (and other) homework directly within Word.</p>
<p>On the left hand side of the Mathematics screen is a calculator like device, that is really just a shortcut to the various formulas that are supported.</p>
<p><a href="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_thumb.png" width="163" height="501" /></a></p>
<p>It is the worksheet window where the real lifting is done. Here you can see how the system explains how a simple equation is solved:</p>
<p><a href="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_3.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_thumb_3.png" width="381" height="517" /></a></p>
<p>It sounds like a cliché, but there are just too many features to easily explain, so you really have to have a go yourself and download it!</p>
<p><a href="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_4.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_thumb_4.png" width="507" height="446" /></a></p>
<p>If you happen to run Mac or Linux there is of course the (also free) option of <a href="http://www.geogebra.org" target="_blank">GeoGebra</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/276/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=276&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/10/30/microsoft-mathematics-an-amazing-freebie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>

		<media:content url="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_thumb_3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://blog.hejndorf.dk/Microsoft-Mathematics--_FCC0/image_thumb_4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Using C# &#8220;dynamic&#8221; with SqlDataReader</title>
		<link>http://phejndorf.wordpress.com/2011/10/30/using-c-dynamic-with-sqldatareader/</link>
		<comments>http://phejndorf.wordpress.com/2011/10/30/using-c-dynamic-with-sqldatareader/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 14:16:48 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/10/30/using-c-dynamic-with-sqldatareader/</guid>
		<description><![CDATA[Type safety is, in my opinion, a lot better than sliced bread. But though the dynamic keyword has to be used very carefully, I still think there are places where it can be an advantage to bring it into play. For instance when accessing data via SqlDataReader in a dynamic fashion. To that end I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=274&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Type safety is, in my opinion, a lot better than sliced bread. But though the dynamic keyword has to be used very carefully, I still think there are places where it can be an advantage to bring it into play.</p>
<p>For instance when accessing data via SqlDataReader in a dynamic fashion. To that end I suggest wrapping the data reader in a construct that will allow you to return a dynamic class where the columns are accessible by name and not a string reference. This can be done via an ExpandoObject that makes it possible to work with the dynamic class as if it was a dictionary:</p>
<pre style="width:708px;height:189px;" class="code"><span style="color:blue;">private dynamic </span>SqlDataReaderToExpando(<span style="color:#2b91af;">SqlDataReader </span>reader)
{
    <span style="color:blue;">var </span>expandoObject = <span style="color:blue;">new </span><span style="color:#2b91af;">ExpandoObject</span>() <span style="color:blue;">as </span><span style="color:#2b91af;">IDictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt;;

    <span style="color:blue;">for </span>(<span style="color:blue;">var </span>i = 0; i &lt; reader.FieldCount; i++)
        expandoObject.Add(reader.GetName(i), reader[i]);

    <span style="color:blue;">return </span>expandoObject;
}</pre>
<p>To create a method for returning the elements of a Sql query in a dynamic fashion can then be implemented like so:</p>
<pre style="width:707px;height:370px;" class="code"><span style="color:blue;">private </span><span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:blue;">dynamic</span>&gt; GetDynamicSqlData(<span style="color:blue;">string </span>connectionstring, <span style="color:blue;">string </span>sql)
{
    <span style="color:blue;">using </span>(<span style="color:blue;">var </span>conn = <span style="color:blue;">new </span><span style="color:#2b91af;">SqlConnection</span>(connectionstring))
    {
        <span style="color:blue;">using </span>(<span style="color:blue;">var </span>comm = <span style="color:blue;">new </span><span style="color:#2b91af;">SqlCommand</span>(sql, conn))
        {
            conn.Open();
            <span style="color:blue;">using </span>(<span style="color:blue;">var </span>reader = comm.ExecuteReader())
            {
                <span style="color:blue;">while </span>(reader.Read())
                {
                    <span style="color:blue;">yield return </span>SqlDataReaderToExpando(reader);
                }
            }
            conn.Close();
        }
    }
}</pre>
<p>&#160;</p>
<p>There are of course all the usual problems with late binding that misspelling and erroneous datatypes won’t be caught until you run the code, but still I find it more elegant than accessing the SqlDataReader’s columns with column-name strings as indexers. And in case you later on decide to make the IEnumerable use an actual class, it will not break the code. This can be done as shown here, where you have a class of T that maps to your database-request:</p>
<pre style="width:748px;height:578px;" class="code"><span style="color:blue;">private static </span><span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; GetSqlData&lt;T&gt;(<span style="color:blue;">string </span>connectionstring, <span style="color:blue;">string </span>sql)
{
    <span style="color:blue;">var </span>properties = <span style="color:blue;">typeof </span>(T).GetProperties();

    <span style="color:blue;">using </span>(<span style="color:blue;">var </span>conn = <span style="color:blue;">new </span><span style="color:#2b91af;">SqlConnection</span>(connectionstring))
    {
        <span style="color:blue;">using </span>(<span style="color:blue;">var </span>comm = <span style="color:blue;">new </span><span style="color:#2b91af;">SqlCommand</span>(sql, conn))
        {
            conn.Open();
            <span style="color:blue;">using </span>(<span style="color:blue;">var </span>reader = comm.ExecuteReader())
            {
                <span style="color:blue;">while </span>(reader.Read())
                {
                    <span style="color:green;">// http://blog.benhall.me.uk/2006/08/creating-objects-dynamically-with-c-20.html
                    </span><span style="color:blue;">var </span>element = <span style="color:#2b91af;">Activator</span>.CreateInstance&lt;T&gt;();

                    <span style="color:blue;">foreach </span>(<span style="color:blue;">var </span>f <span style="color:blue;">in </span>properties)
                    {
                        <span style="color:blue;">var </span>o = reader[f.Name];
                        <span style="color:blue;">if </span>(o.GetType() != <span style="color:blue;">typeof</span>(<span style="color:#2b91af;">DBNull</span>)) f.SetValue(element, o, <span style="color:blue;">null</span>);
                    }
                    <span style="color:blue;">yield return </span>element;
                }
            }
            conn.Close();
        }
    }
}</pre>
<p>&#160;</p>
<p>Actually the little Activator.CreateInstance&lt;T&gt; trick can nowadays also be coded with a new T() if you add a type-constraint on the method (where T : new()), but internally it’s still Activator.CreateInstance&lt;T&gt; so this version is basically just sugar-coating:</p>
<pre style="width:711px;height:549px;" class="code"><span style="color:blue;">private static </span><span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; GetSqlData&lt;T&gt;(<span style="color:blue;">string </span>connectionstring, <span style="color:blue;">string </span>sql) <span style="color:blue;">where </span>T : <span style="color:blue;">new</span>()
{
    <span style="color:blue;">var </span>properties = <span style="color:blue;">typeof </span>(T).GetProperties();

    <span style="color:blue;">using </span>(<span style="color:blue;">var </span>conn = <span style="color:blue;">new </span><span style="color:#2b91af;">SqlConnection</span>(connectionstring))
    {
        <span style="color:blue;">using </span>(<span style="color:blue;">var </span>comm = <span style="color:blue;">new </span><span style="color:#2b91af;">SqlCommand</span>(sql, conn))
        {
            conn.Open();
            <span style="color:blue;">using </span>(<span style="color:blue;">var </span>reader = comm.ExecuteReader())
            {
                <span style="color:blue;">while </span>(reader.Read())
                {
                    <span style="color:blue;">var </span>element = <span style="color:blue;">new </span>T();

                    <span style="color:blue;">foreach </span>(<span style="color:blue;">var </span>f <span style="color:blue;">in </span>properties)
                    {
                        <span style="color:blue;">var </span>o = reader[f.Name];
                        <span style="color:blue;">if </span>(o.GetType() != <span style="color:blue;">typeof</span>(<span style="color:#2b91af;">DBNull</span>)) f.SetValue(element, o, <span style="color:blue;">null</span>);
                    }
                    <span style="color:blue;">yield return </span>element;
                }
            }
            conn.Close();
        }
    }
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/274/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=274&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/10/30/using-c-dynamic-with-sqldatareader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting A Default Recovery Model For Sql Server</title>
		<link>http://phejndorf.wordpress.com/2011/10/12/setting-a-default-recovery-model-for-sql-server/</link>
		<comments>http://phejndorf.wordpress.com/2011/10/12/setting-a-default-recovery-model-for-sql-server/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 08:19:45 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/10/12/setting-a-default-recovery-model-for-sql-server/</guid>
		<description><![CDATA[Changing the default recovery model (and other settings) for every new database you create on a server is managed by setting the attributes of the “Model” database. As the documentation states: “A new database inherits its recovery model from the model database.” In my case, working mostly with test-servers in VMware, it means that I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=269&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Changing the default recovery model (and other settings) for every new database you create on a server is managed by setting the attributes of the “Model” database.</p>
<p>As the <a href="http://msdn.microsoft.com/en-us/library/ms175987.aspx" target="_blank">documentation</a> states: “A new database inherits its recovery model from the <strong>model</strong> database.” </p>
<p>In my case, working mostly with test-servers in VMware, it means that I generally change the installed defaults like this:</p>
<p><font face="Courier New"><span style="color:blue;">USE </span>[master]      <br /></font><font face="Courier New"><span style="color:blue;">GO       <br />ALTER DATABASE </span>[model] <span style="color:blue;">SET AUTO_SHRINK ON WITH </span>NO_WAIT      <br /></font><font face="Courier New"><span style="color:blue;">GO       <br />ALTER DATABASE </span>[model] <span style="color:blue;">SET RECOVERY SIMPLE WITH </span>NO_WAIT      <br /></font><span style="color:blue;"><font face="Courier New">GO       <br /></font></span></p>
<p><a href="http://phejndorf.files.wordpress.com/2011/10/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://phejndorf.files.wordpress.com/2011/10/image_thumb.png?w=545&#038;h=324" width="545" height="324" /></a><span style="color:blue;"><font face="Courier New"></font></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/269/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=269&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/10/12/setting-a-default-recovery-model-for-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>

		<media:content url="http://phejndorf.files.wordpress.com/2011/10/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Virtualizing Windows 8 Developer Preview &#8211; Now Playing On VMWare Player 4</title>
		<link>http://phejndorf.wordpress.com/2011/10/06/virtualizing-windows-8-developer-previewnow-on-vm-ware-player/</link>
		<comments>http://phejndorf.wordpress.com/2011/10/06/virtualizing-windows-8-developer-previewnow-on-vm-ware-player/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 12:06:30 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/10/06/virtualizing-windows-8-developer-previewnow-on-vm-ware-player/</guid>
		<description><![CDATA[VMware Player version 4 is now available, and can be used with the Windows 8 Developer Preview. However, you can’t just install it as Windows 7 as there is no serial available, but the installation is still pretty simple. I found a good introduction to the steps here: http://www.eightforums.com/tutorials/2899-vmware-player-install-windows-8-developer-preview.html Note that there is an issue [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=267&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>VMware Player version 4 is now <a href="http://www.vmware.com/products/player/overview.html" target="_blank">available</a>, and can be used with the Windows 8 Developer Preview.</p>
<p>However, you can’t just install it as Windows 7 as there is no serial available, but the installation is still pretty simple.</p>
<p>I found a good introduction to the steps here: <a title="http://www.eightforums.com/tutorials/2899-vmware-player-install-windows-8-developer-preview.html" href="http://www.eightforums.com/tutorials/2899-vmware-player-install-windows-8-developer-preview.html">http://www.eightforums.com/tutorials/2899-vmware-player-install-windows-8-developer-preview.html</a></p>
<p>Note that there is an issue with the VMware tools in 64 bit mode.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=267&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/10/06/virtualizing-windows-8-developer-previewnow-on-vm-ware-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>
	</item>
		<item>
		<title>Virtualizing Windows 8 Developer Preview</title>
		<link>http://phejndorf.wordpress.com/2011/09/14/virtualizing-windows-8-developer-preview/</link>
		<comments>http://phejndorf.wordpress.com/2011/09/14/virtualizing-windows-8-developer-preview/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 08:44:25 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/09/14/virtualizing-windows-8-developer-preview/</guid>
		<description><![CDATA[It would seem a fairly obvious choice to try out the new, exciting Windows 8 in a virtual environment. Apparently virtualizing the Windows 8 Developer Preview isn’t so easy, however – at least it doesn’t seem work&#160; in Virtual PC 2007 and VMware Player 3.0.1, but quickly stops with this message: I’m currently trying with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=261&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It would seem a fairly obvious choice to try out the new, exciting Windows 8 in a virtual environment.</p>
<p>Apparently virtualizing the Windows 8 Developer Preview isn’t so easy, however – at least it doesn’t seem work&#160; in Virtual PC 2007 and VMware Player 3.0.1, but quickly stops with this message:</p>
<p><a href="http://phejndorf.files.wordpress.com/2011/09/clip_image002.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="clip_image002" border="0" alt="clip_image002" src="http://phejndorf.files.wordpress.com/2011/09/clip_image002_thumb.jpg?w=347&#038;h=190" width="347" height="190" /></a></p>
<p>I’m currently trying with <a href="http://www.virtualbox.org/" target="_blank">VirtualBox</a>, and at least it’s now brought me to the “Installing Windows” screen – I’ll report back if that works any better. Currently it’s been “pining for the fiords” or whatever for a good while:</p>
<p><a href="http://phejndorf.files.wordpress.com/2011/09/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://phejndorf.files.wordpress.com/2011/09/image_thumb1.png?w=230&#038;h=108" width="230" height="108" /></a></p>
<p><strong>Update.</strong> I think it was disk formatting that took a while, but here is Windows 8 Developer Preview 32bit in all its glory running in VirtualBox :</p>
<p><a href="http://phejndorf.files.wordpress.com/2011/09/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://phejndorf.files.wordpress.com/2011/09/image_thumb2.png?w=595&#038;h=500" width="595" height="500" /></a></p>
<p>I only just got it running, so no testing so far. It seems that VirtualBox is the way to go for the time being.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/261/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=261&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/09/14/virtualizing-windows-8-developer-preview/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>

		<media:content url="http://phejndorf.files.wordpress.com/2011/09/clip_image002_thumb.jpg" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>

		<media:content url="http://phejndorf.files.wordpress.com/2011/09/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://phejndorf.files.wordpress.com/2011/09/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>A lookup table of Visual Studio Keyboard Shortcuts (KeyBindings)</title>
		<link>http://phejndorf.wordpress.com/2011/07/30/a-lookup-table-of-visual-studio-keyboard-shortcuts-keybindings/</link>
		<comments>http://phejndorf.wordpress.com/2011/07/30/a-lookup-table-of-visual-studio-keyboard-shortcuts-keybindings/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 13:13:33 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/07/30/a-lookup-table-of-visual-studio-keyboard-shortcuts-keybindings/</guid>
		<description><![CDATA[I’ve really wanted to be faster at my VS 2010 work, and to that end I think that getting to know and and practice the keyboard shortcuts is a good idea&#8230;. I know there are quite of overviews out there like Scott Guthrie&#8217;s and DoFactory&#8217;s, but I wanted my own structured data to be able [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=253&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve really wanted to be faster at my VS 2010 work, and to that end I think that getting to know and and practice the keyboard shortcuts is a good idea&#8230;.</p>
<p>I know there are quite of overviews out there like <a href="http://weblogs.asp.net/scottgu/archive/2010/07/29/visual-studio-2010-keyboard-shortcuts.aspx" target="_blank">Scott Guthrie&#8217;s</a> and <a href="http://www.dofactory.com/ShortCutKeys/ShortCutKeys.aspx" target="_blank">DoFactory&#8217;s</a>, but I wanted my own structured data to be able as filter, group and search as I please.</p>
<p>Much googling took me here at <a href="http://msdn.microsoft.com/en-us/library/ms247076.aspx#1" target="_blank">MSDN</a> where <a href="http://msdn.microsoft.com/en-us/library/community/user/843240.aspx" target="_blank">Kevin Buchs</a> has added a nice VS 2010 macro for extracting the data.</p>
<p>I’ve modified Kevin’s implementation a bit, in order to be able to import it more easily into an Excel sheet (download sample <a href="http://blog.hejndorf.dk/vs2010standardkeys.zip" target="_blank">here</a> with the default bindings), so here’s my version of the macro:</p>
<pre class="code"><span style="color:blue;">Sub </span>GetAllCommands3()
        <span style="color:green;">' http://msdn.microsoft.com/en-us/library/ms247076.aspx#1

        </span><span style="color:blue;">Dim </span>new_window = DTE.ItemOperations.NewFile(<span style="color:#a31515;">&quot;General\Text File&quot;</span>)
        <span style="color:blue;">Dim </span>doc = new_window.Document
        <span style="color:blue;">Dim </span>textDoc = <span style="color:blue;">CType</span>(doc.Object(<span style="color:#a31515;">&quot;TextDocument&quot;</span>), TextDocument)
        textDoc.StartPoint.CreateEditPoint() <span style="color:green;">' Creates an &quot;edit point&quot; at the beginning of the document

        ' Tab-separated per command / binding
        </span><span style="color:blue;">For Each </span>cmd <span style="color:blue;">In </span>DTE.Commands
            <span style="color:blue;">If Not </span>cmd.Name.Trim().Equals(<span style="color:#a31515;">&quot;&quot;</span>) <span style="color:blue;">Then
  </span><span style="color:green;">              </span><span style="color:blue;">Dim </span>line1 = cmd.Name.ToString().Split(<span style="color:#a31515;">&quot;.&quot;</span>)(0) + vbTab + cmd.Name.ToString()

                <span style="color:blue;">For Each </span>binding <span style="color:blue;">In </span>cmd.Bindings
                    <span style="color:blue;">Dim </span>split = binding.ToString().Split(<span style="color:#a31515;">&quot;::&quot;</span>)
                    <span style="color:blue;">Dim </span>line2 = line1 + vbTab + split(0) + vbTab + split(2) + vbCrLf
                    textDoc.Selection.Insert(line2)
                <span style="color:blue;">Next
            End If
        Next
    End Sub</span></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/253/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=253&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/07/30/a-lookup-table-of-visual-studio-keyboard-shortcuts-keybindings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>
	</item>
		<item>
		<title>Implementing your own Linq &#8220;equals&#8221; join operator</title>
		<link>http://phejndorf.wordpress.com/2011/07/20/implementing-your-own-linq-equals-join-operator/</link>
		<comments>http://phejndorf.wordpress.com/2011/07/20/implementing-your-own-linq-equals-join-operator/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 09:46:19 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/07/20/implementing-your-own-linq-equals-join-operator/</guid>
		<description><![CDATA[Today I needed to do a Linq join on two sets of class that needed to have a custom join, ie the concept of equality had to be determined by a rule in the class. The problem is, that .Net doesn’t have an interface that facilitates this, and that you have to have knowledge about [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=252&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I needed to do a Linq join on two sets of class that needed to have a custom join, ie the concept of equality had to be determined by a rule in the class.</p>
<p>The problem is, that .Net doesn’t have an interface that facilitates this, and that you have to have knowledge about the inner workings of the Linq join/equals.</p>
<p>Here is how it works:</p>
<p>1. Linq will call the two compared classes GetHashCode() method to determine if they have the same hash-code.</p>
<p>2. If they don’t they are assumed to be unequal.</p>
<p>3. If the hashcodes are equal, Linq goes on to the class’s Equals(object o) method to determine equality.</p>
<p>This is implemented by reasons of performance. The hash-metod only confirms &#8211; as a truly unique hash-code doesn’t exist in reality &#8211; that the two classes <strong>might</strong> be equal, and not until then is the presumably costlier Equals executed to determine acutal equality.</p>
<p>So because of this you need to implement both a GetHashCode() and an Equals() method. By implementing the IEquatable&lt;T&gt;() interface you get the Equals() method, but then you must implement GetHashCode() by overriding it, otherwise your Equals() method may not ever be called as the base GetHashCode() method will be different for all (most) instances, and to Linq all classes will be different!</p>
<p>You can do several things in your GetHashTable() method – the simplest of which is to return a constant, in which case Linq will always quickly move on to the Equals() method. You can also select one or more fields of the class to hash on, I guess it is a design choice based on your knowledge of the actual data that will get the best performance.</p>
<p>Stackoverflow has a good posting <a href="http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode" target="_blank">here</a> on how to do the hash generation. I personally think this one looked pretty neat:</p>
<pre><code>return new { A = PropA, B = PropB, C = PropC, D = PropD }.GetHashCode(); </code></pre>
<p>But, as mentioned, it’s all about speed (and memory), and a question whether most elements are actually unequal or equal, so some testing will be in place in each case.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/252/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=252&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/07/20/implementing-your-own-linq-equals-join-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>
	</item>
		<item>
		<title>WCF Web Api: oData format doesn&#8217;t mean oData service</title>
		<link>http://phejndorf.wordpress.com/2011/07/15/wcf-web-api-odata-format-doesnt-mean-odata-service/</link>
		<comments>http://phejndorf.wordpress.com/2011/07/15/wcf-web-api-odata-format-doesnt-mean-odata-service/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 09:05:01 +0000</pubDate>
		<dc:creator>phejndorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://phejndorf.wordpress.com/2011/07/15/wcf-web-api-odata-format-doesnt-mean-odata-service/</guid>
		<description><![CDATA[Over the years I must admit that the WCF acronym to me has had the effect of instilling huge amounts of fear and loathing. We have inhouse some really complex stuff that requires gargatuan declarative angle-bracketed configuration monsters that are next to impossible to figure out for most people. One makes changes, fearing both life [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=249&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Over the years I must admit that the WCF acronym to me has had the effect of instilling huge amounts of fear and loathing. We have inhouse some really complex stuff that requires gargatuan declarative angle-bracketed configuration monsters that are next to impossible to figure out for most people. One makes changes, fearing both life and mental health. WCF, in short, is one of those Microsoft inventions that make you wonder why you didn’t train to become something else – a plumber for instance.</p>
<p>Recently I’ve been playing a bit with the <a href="http://wcf.codeplex.com/wikipage?title=WCF HTTP" target="_blank">WCF Web Api</a>, however, and it seems like a really easy way to get some REST-ful data over the wire. When you return a collection of data from Web Api, you can elect to return it&#160; as an IQueryable in which case you will, as it says,&#160; be “Enabling OData query support” .</p>
<p>Mark that phrasing carefully: You are not enabling OData as such – it’s just that you can now use the OData URI <strong>syntax</strong> when you retrieve data. So don’t fall into the same hole that I did and think that you have full blown OData!</p>
<p>Other than that misconception on my part, it’s all thumbs up for this initiative to focus (and tame) the WCF monster into something more immediately&#160; useful. The WCF Data Services (OData) effort is the same story. Now I just have to convince the rest of my fellow devs and customers that the days of heavyweight WCF/SOAP are coming to a an end in a lot (most) scenarios…</p>
<p>With that said, do go check out Glenn Block’s speech at Mix 11: <a href="http://channel9.msdn.com/Events/MIX/MIX11/FRM14" target="_blank">&quot;There&#8217;s a URI for that&quot;</a>.</p>
<p> PS. I just discovered that we have one SOAP implementation where all data is exchanged with a mobile client as delimited strings, in order to conserve bandwith by eliminating a lot of XML tags!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phejndorf.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phejndorf.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phejndorf.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phejndorf.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phejndorf.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phejndorf.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phejndorf.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phejndorf.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phejndorf.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phejndorf.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phejndorf.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phejndorf.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phejndorf.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phejndorf.wordpress.com/249/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phejndorf.wordpress.com&amp;blog=10315839&amp;post=249&amp;subd=phejndorf&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phejndorf.wordpress.com/2011/07/15/wcf-web-api-odata-format-doesnt-mean-odata-service/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/188c850f0ea2fea2bababc9414158e8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phejndorf</media:title>
		</media:content>
	</item>
	</channel>
</rss>
