<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>An Irishman Down Under</title>
  <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/" />
  <link rel="self" href="http://blog.keithpatton.com/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2008-10-06T12:00:57.3425000-00:00</updated>
  <author>
    <name>Keith Patton</name>
  </author>
  <subtitle>Keith Patton's Blog</subtitle>
  <id>http://blog.keithpatton.com/</id>
  <generator uri="http://www.dasblog.net" version="1.9.6264.0">DasBlog</generator>
  <entry>
    <title>What&amp;rsquo;s the next piece of open source software that Microsoft should embrace?</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/10/06/Whatrsquos+The+Next+Piece+Of+Open+Source+Software+That+Microsoft+Should+Embrace.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,0e875094-3ff5-47c9-b2a0-01c2131de61d.aspx</id>
    <published>2008-10-06T12:00:57.3425000-00:00</published>
    <updated>2008-10-06T12:00:57.3425000-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
After the recent announcement by Scott Guthrie that JQuery would receive official
support from Microsoft (<a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx">http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx</a>),
many people see that as the heralding of a new dawn. 
</p>
        <p>
We missed out on NUnit (MsTest), NDoc (Sandcastle) and NHibernate (Linq to SQL/Entity
Framework) for sure, but what do you think should be embraced next?
</p>
        <p>
 
</p>
        <p>
Post your answer here:
</p>
        <a title="http://stackoverflow.com/questions/173996/whats-the-next-piece-of-open-source-software-that-microsoft-should-embrace" href="http://stackoverflow.com/questions/173996/whats-the-next-piece-of-open-source-software-that-microsoft-should-embrace">http://stackoverflow.com/questions/173996/whats-the-next-piece-of-open-source-software-that-microsoft-should-embrace</a>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=0e875094-3ff5-47c9-b2a0-01c2131de61d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Bail Out Truth</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/09/27/Bail+Out+Truth.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,dee377ae-9a71-4e3d-82c5-d8aefdd1fe6d.aspx</id>
    <published>2008-09-27T04:38:29.2953750-00:00</published>
    <updated>2008-09-27T04:38:29.2953750-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blog.keithpatton.com/content/binary/WindowsLiveWriter/BailOutTruth_EA0D/wpcbe080924_2.gif">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="394" alt="wpcbe080924" src="http://blog.keithpatton.com/content/binary/WindowsLiveWriter/BailOutTruth_EA0D/wpcbe080924_thumb.gif" width="589" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=dee377ae-9a71-4e3d-82c5-d8aefdd1fe6d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Warriors Stuff the Chooks</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/09/25/Warriors+Stuff+The+Chooks.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,0f181c7e-6cb1-4983-bd61-9a028ccd0bc0.aspx</id>
    <published>2008-09-25T10:29:46.9980000-00:00</published>
    <updated>2008-09-25T10:31:20.5141250-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <category term="Sport" label="Sport" scheme="http://blog.keithpatton.com/CategoryView,category,Sport.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div style="margin-left: 10px; margin-bottom: 10px;">
          <object type="application/x-shockwave-flash" data="http://www.flickr.com/apps/video/stewart.swf?v=60247" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="260" height="195">
            <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=0399f2f883&amp;photo_id=2887405738&amp;show_info_box=true" />
            <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=60247" />
            <param name="bgcolor" value="#000000" />
            <param name="allowFullScreen" value="true" />
            <embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=60247" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=0399f2f883&amp;photo_id=2887405738&amp;flickr_show_info_box=true" width="260" height="195">
            </embed>
          </object>
          <br />
          <span style="font-size: 0.9em; margin-top: 0px;">
            <a href="http://www.flickr.com/photos/anirishmandownunder/2887405738/">19092008085</a>
            <br />
Originally uploaded by <a href="http://www.flickr.com/people/anirishmandownunder/">An
Irishman Down Under</a></span>
        </div>
Woo hoo, bring on manly!<br clear="all" /><img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=0f181c7e-6cb1-4983-bd61-9a028ccd0bc0" /></div>
    </content>
  </entry>
  <entry>
    <title>Tommy shopping and at the zoo</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/09/25/Tommy+Shopping+And+At+The+Zoo.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,a2b54e1c-787a-497b-b8db-aa649ad1f322.aspx</id>
    <published>2008-09-25T10:21:03.0453750-00:00</published>
    <updated>2008-09-25T10:21:03.0453750-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="23092008560" href="http://www.flickr.com/photos/27592284@N00/2887397102/">
            <img alt="23092008560" src="http://static.flickr.com/3111/2887397102_c791305331.jpg" border="0" />
          </a>
          <a title="23092008559" href="http://www.flickr.com/photos/27592284@N00/2887396976/">
            <img alt="23092008559" src="http://static.flickr.com/3222/2887396976_2577472993.jpg" border="0" />
          </a>
          <a title="23092008558" href="http://www.flickr.com/photos/27592284@N00/2886562293/">
            <img alt="23092008558" src="http://static.flickr.com/3159/2886562293_0b51f24d4f.jpg" border="0" />
          </a>
          <a title="23092008556" href="http://www.flickr.com/photos/27592284@N00/2887396696/">
            <img alt="23092008556" src="http://static.flickr.com/3285/2887396696_bae6a23a94.jpg" border="0" />
          </a>
          <a title="23092008554" href="http://www.flickr.com/photos/27592284@N00/2886562001/">
            <img alt="23092008554" src="http://static.flickr.com/3283/2886562001_ef08c5787c.jpg" border="0" />
          </a>
          <a title="23092008552" href="http://www.flickr.com/photos/27592284@N00/2887396372/">
            <img alt="23092008552" src="http://static.flickr.com/3006/2887396372_47052daed8.jpg" border="0" />
          </a>
          <a title="23092008550" href="http://www.flickr.com/photos/27592284@N00/2886561713/">
            <img alt="23092008550" src="http://static.flickr.com/3174/2886561713_4bcb49ae3c.jpg" border="0" />
          </a>
          <a title="23092008548" href="http://www.flickr.com/photos/27592284@N00/2887396072/">
            <img alt="23092008548" src="http://static.flickr.com/3296/2887396072_db7885483f.jpg" border="0" />
          </a>
          <a title="30082008541" href="http://www.flickr.com/photos/27592284@N00/2886561449/">
            <img alt="30082008541" src="http://static.flickr.com/3265/2886561449_e8fbfdf1b4.jpg" border="0" />
          </a>
          <a title="30082008540" href="http://www.flickr.com/photos/27592284@N00/2887395754/">
            <img alt="30082008540" src="http://static.flickr.com/3183/2887395754_4502b52aae.jpg" border="0" />
          </a>
          <a title="30082008538" href="http://www.flickr.com/photos/27592284@N00/2887395624/">
            <img alt="30082008538" src="http://static.flickr.com/3080/2887395624_75e48a86dc.jpg" border="0" />
          </a>
          <a title="16082008531" href="http://www.flickr.com/photos/27592284@N00/2886560927/">
            <img alt="16082008531" src="http://static.flickr.com/3125/2886560927_fc6c6eaace.jpg" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=a2b54e1c-787a-497b-b8db-aa649ad1f322" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Monetary Reform the only answer to global credit crisis</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/09/20/Monetary+Reform+The+Only+Answer+To+Global+Credit+Crisis.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,44e5fcad-8950-4df1-bd42-2af72f9ca85c.aspx</id>
    <published>2008-09-20T04:22:36.5671250-00:00</published>
    <updated>2008-09-20T04:22:59.7546250-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I believe the problems experienced around the world with the global credit crisis
arise from a fundamental problem in our definition of money and the way most modern
industrialized nations have structured control over management of the money supply.
</p>
        <p>
Neither Barack Obama or John McCain have any intention of enacting any sort of monetary
reform as far as i can tell. Unfortunately, the only person who i think agrees with
all this in the US is Ron Paul <a href="http://www.campaignforliberty.com/">http://www.campaignforliberty.com/</a>,
and i don’t agree with much else of his! 
</p>
        <p>
          <a href="http://en.wikipedia.org/wiki/American_Monetary_Institute">http://en.wikipedia.org/wiki/American_Monetary_Institute</a>
        </p>
        <p>
“If <a href="http://en.wikipedia.org/wiki/Money">money</a> is a <a href="http://en.wikipedia.org/wiki/Commodity">commodity</a> to
be traded, then all that matters is that the money is 100% backed by some commodity,
like <a href="http://en.wikipedia.org/wiki/Gold">gold</a> or <a href="http://en.wikipedia.org/wiki/Silver">silver</a> for
example. If money is credit, then it makes sense that bankers control it, as they
do in the <a href="http://en.wikipedia.org/wiki/United_States">United States</a> today.
But if money is an artifact of law, whose value is derived from law (payment of taxes
and legal tender laws) then the Institute argues it would only be proper for the government
to issue, and control the <a href="http://en.wikipedia.org/wiki/Money_supply">money
supply</a>.”
</p>
        <p>
          <a href="http://www.monetary.org/need_for_monetary_reform.html">http://www.monetary.org/need_for_monetary_reform.html</a>
        </p>
        <p>
Monetary reform is achieved in 3 parts which must be enacted together for it to work.
Any one or any two of them alone won’t do it, but could actually further harm
the monetary situation.
</p>
        <p>
1. First, <b>incorporate the Federal Reserve System into the U.S. Treasury</b> where
all new money is created by government as money, not interest-bearing debt, and spent
into circulation to promote the general welfare; monitored to be neither inflationary
nor deflationary.
</p>
        <p>
2. Second, <b>halt the banks privilege to create money</b> by ending the fractional
reserve system in a gentle and elegant way. All the past monetized private credit
is converted into U.S. government money. Banks then act as intermediaries accepting
savings deposits and loaning them out to borrowers; what people think they do now.
</p>
        <p>
3. Third, <b>spend new money into circulation on infrastructure, including education
and healthcare </b>needed for a growing society, starting with the $1.6 trillion that
the American Society of Civil Engineers estimate is needed for infrastructure repair;
creating good jobs across our nation, re-invigorating local economies and re-funding
government at all levels.
</p>
        <p>
REVOLUTION!
</p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=44e5fcad-8950-4df1-bd42-2af72f9ca85c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Tommy on the Train and in the Snow!</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/09/08/Tommy+On+The+Train+And+In+The+Snow.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,a546b999-51e8-469c-abbc-15a90bec732a.aspx</id>
    <published>2008-09-08T11:40:19.3718750-00:00</published>
    <updated>2008-09-08T11:40:19.3718750-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="DSC03595" href="http://www.flickr.com/photos/27592284@N00/2839714440/">
            <img alt="DSC03595" src="http://static.flickr.com/3074/2839714440_4b407bf8bb.jpg" border="0" />
          </a>
          <a title="DSC03593" href="http://www.flickr.com/photos/27592284@N00/2838880641/">
            <img alt="DSC03593" src="http://static.flickr.com/3220/2838880641_9671c21d5e.jpg" border="0" />
          </a>
          <a title="DSC03591" href="http://www.flickr.com/photos/27592284@N00/2838880471/">
            <img alt="DSC03591" src="http://static.flickr.com/3160/2838880471_44de56a690.jpg" border="0" />
          </a>
          <a title="DSC03587" href="http://www.flickr.com/photos/27592284@N00/2839713898/">
            <img alt="DSC03587" src="http://static.flickr.com/3223/2839713898_2f871328c3.jpg" border="0" />
          </a>
          <a title="DSC03597" href="http://www.flickr.com/photos/27592284@N00/2839713740/">
            <img alt="DSC03597" src="http://static.flickr.com/3150/2839713740_58d2548e17.jpg" border="0" />
          </a>
          <a title="DSC03590" href="http://www.flickr.com/photos/27592284@N00/2838879917/">
            <img alt="DSC03590" src="http://static.flickr.com/3057/2838879917_060381f96d.jpg" border="0" />
          </a>
          <a title="DSC03587" href="http://www.flickr.com/photos/27592284@N00/2839713438/">
            <img alt="DSC03587" src="http://static.flickr.com/3170/2839713438_d664c6bc8c.jpg" border="0" />
          </a>
          <a title="DSC03586" href="http://www.flickr.com/photos/27592284@N00/2838879597/">
            <img alt="DSC03586" src="http://static.flickr.com/3009/2838879597_681b3766d6.jpg" border="0" />
          </a>
          <a title="DSC03585" href="http://www.flickr.com/photos/27592284@N00/2839712996/">
            <img alt="DSC03585" src="http://static.flickr.com/3156/2839712996_a9fcb4f09d.jpg" border="0" />
          </a>
          <a title="DSC03582" href="http://www.flickr.com/photos/27592284@N00/2838879155/">
            <img alt="DSC03582" src="http://static.flickr.com/3019/2838879155_22a9c1ea98.jpg" border="0" />
          </a>
          <a title="DSC03581" href="http://www.flickr.com/photos/27592284@N00/2839712604/">
            <img alt="DSC03581" src="http://static.flickr.com/3080/2839712604_08da5fda34.jpg" border="0" />
          </a>
          <a title="DSC03579" href="http://www.flickr.com/photos/27592284@N00/2839712406/">
            <img alt="DSC03579" src="http://static.flickr.com/3227/2839712406_68da1ba5ee.jpg" border="0" />
          </a>
          <a title="DSC03576" href="http://www.flickr.com/photos/27592284@N00/2838878655/">
            <img alt="DSC03576" src="http://static.flickr.com/3142/2838878655_be6b2f0046.jpg" border="0" />
          </a>
          <a title="DSC03574" href="http://www.flickr.com/photos/27592284@N00/2838878485/">
            <img alt="DSC03574" src="http://static.flickr.com/3110/2838878485_6f119f91df.jpg" border="0" />
          </a>
          <a title="DSC03573" href="http://www.flickr.com/photos/27592284@N00/2838878279/">
            <img alt="DSC03573" src="http://static.flickr.com/3236/2838878279_1f9ec9fc52.jpg" border="0" />
          </a>
          <a title="DSC03561" href="http://www.flickr.com/photos/27592284@N00/2838878137/">
            <img alt="DSC03561" src="http://static.flickr.com/3113/2838878137_c4855a0852.jpg" border="0" />
          </a>
          <a title="DSC03558" href="http://www.flickr.com/photos/27592284@N00/2838877971/">
            <img alt="DSC03558" src="http://static.flickr.com/3084/2838877971_69eae22b54.jpg" border="0" />
          </a>
          <a title="DSC03565" href="http://www.flickr.com/photos/27592284@N00/2838877785/">
            <img alt="DSC03565" src="http://static.flickr.com/3115/2838877785_1655727ba8.jpg" border="0" />
          </a>
          <a title="DSC03569" href="http://www.flickr.com/photos/27592284@N00/2838877561/">
            <img alt="DSC03569" src="http://static.flickr.com/3086/2838877561_7fe3d955e6.jpg" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=a546b999-51e8-469c-abbc-15a90bec732a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Entity Framework - Key Extension Methods</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/08/16/Entity+Framework+Key+Extension+Methods.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,57951fac-3b68-4330-a3f6-aa545cd85da4.aspx</id>
    <published>2008-08-16T03:26:05.6875000-00:00</published>
    <updated>2008-08-16T03:40:40.9531250-00:00</updated>
    <category term="Technical" label="Technical" scheme="http://blog.keithpatton.com/CategoryView,category,Technical.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We created the following extension methods for entity framework to avoid code bloat
in consuming applications when working with these key types. I hope you find them
useful if you are working with the Entity Framework.
</p>
        <p>
 
</p>
        <p>
          <strong>EntityObject</strong>
        </p>
        <p>
/// &lt;summary&gt; 
<br />
/// Extension methods for EntityObject 
<br />
/// &lt;/summary&gt; 
<br />
public static class EntityObjectExtensions 
<br />
{ 
</p>
        <p>
    /// &lt;summary&gt; 
<br />
    /// Gets the original value for a modified entity object's property 
<br />
    /// &lt;/summary&gt; 
<br />
    /// &lt;returns&gt;the value before the property was modified&lt;/returns&gt; 
<br />
    public static T GetOriginalValue&lt;T&gt;(this EntityObject entityObject,
string propertyName) 
<br />
    { 
<br />
        if (entityObject == null) 
<br />
            return default(T); 
<br />
        if (entityObject.EntityState == EntityState.Modified) 
<br />
        { 
<br />
            ObjectContext context
= <font color="#ff0000">[YOUR OBJECT CONTEXT]</font><br />
            ObjectStateEntry
stateEntry = null; 
<br />
            context.ObjectStateManager.TryGetObjectStateEntry(entityObject,
out stateEntry); 
</p>
        <p>
            if (stateEntry
!= null) 
<br />
               
return (T)stateEntry.OriginalValues.GetValue(stateEntry.OriginalValues.GetOrdinal(propertyName)); 
</p>
        <p>
        } 
</p>
        <p>
        // return the value of the property 
<br />
        return (T)entityObject.GetType().GetProperty(propertyName).GetValue(entityObject,
null); 
<br />
    }
</p>
        <p>
          <strong>EntityCollection&lt;T&gt;</strong>
        </p>
        <p>
/// &lt;summary&gt; 
<br />
   /// Extension methods for EntityCollection 
<br />
   /// &lt;/summary&gt; 
<br />
   public static class EntityCollectionExtensions 
<br />
   { 
<br />
       /// &lt;summary&gt; 
<br />
       /// Loads the entity collection if it hasn't
already been loaded 
<br />
       /// &lt;/summary&gt; 
<br />
       /// &lt;typeparam name="T"&gt;Type
of entity collection&lt;/typeparam&gt; 
<br />
       /// &lt;param name="entityCollection"&gt;Entity
collection to potentially load entities into&lt;/param&gt; 
<br />
       /// &lt;param name="entitySource"&gt;The
source entity which has the entity collection relationship (modified or unchanged
only)&lt;/param&gt; 
<br />
       public static void EnsureLoaded&lt;T&gt;(this
EntityCollection&lt;T&gt; entityCollection, EntityObject entitySource) where T : class,
IEntityWithRelationships 
<br />
       { 
<br />
           if (entitySource != null
&amp;&amp; entityCollection != null &amp;&amp; !entityCollection.IsLoaded ) 
<br />
           { 
<br />
              
if (entitySource.EntityState == System.Data.EntityState.Modified || entitySource.EntityState
== System.Data.EntityState.Unchanged) 
<br />
              
{ 
<br />
                  
entityCollection.Load(); 
<br />
              
} 
<br />
           } 
<br />
       } 
</p>
        <p>
       /// &lt;summary&gt; 
<br />
       /// Returns the collection as a queryable type 
<br />
       /// &lt;/summary&gt; 
<br />
       /// &lt;typeparam name="T"&gt;Type
of entity collection&lt;/typeparam&gt; 
<br />
       /// &lt;param name="entityCollection"&gt;Entity
collection to return as a queryable object&lt;/param&gt; 
<br />
       /// &lt;param name="ensureLoaded"&gt;Flag
to determine if to load the collection if it has not been done so already&lt;/param&gt; 
<br />
       /// &lt;returns&gt;Queryable object for the in
memory collection&lt;/returns&gt; 
<br />
       public static IQueryable&lt;T&gt; AsQueryable&lt;T&gt;(this
EntityCollection&lt;T&gt; entityCollection, bool ensureLoaded, EntityObject entitySource)
where T : class, IEntityWithRelationships 
<br />
       { 
<br />
           if (ensureLoaded) 
<br />
              
EnsureLoaded(entityCollection, entitySource); 
<br />
           return entityCollection.AsQueryable(); 
<br />
       }
</p>
        <p>
 
</p>
        <p>
          <strong>EntityReference&lt;T&gt;</strong>
        </p>
        <p>
 
</p>
        <p>
/// &lt;summary&gt; 
<br />
   /// Extension methods for EntityReference 
<br />
   /// &lt;/summary&gt; 
<br />
   public static class EntityReferenceExtensions 
<br />
   { 
</p>
        <p>
       /// &lt;summary&gt; 
<br />
       /// Loads the entity reference or its value if
it hasn't already been loaded. 
<br />
       /// &lt;/summary&gt; 
<br />
       /// &lt;typeparam name="T"&gt;Type
of entity reference&lt;/typeparam&gt; 
<br />
       /// &lt;param name="entitySource"&gt;The
source entity which has the entity reference relationship (added, modified or unchanged
only)&lt;/param&gt; 
<br />
       public static void EnsureLoaded&lt;T&gt;(this
EntityReference&lt;T&gt; entityReference, EntityObject entitySource) where T : class,
IEntityWithRelationships 
<br />
       { 
<br />
           if (entitySource != null
&amp;&amp; entityReference != null &amp;&amp; !entityReference.IsLoaded &amp;&amp;
entityReference.EntityKey != null) 
<br />
           { 
<br />
              
if (entitySource.EntityState == System.Data.EntityState.Added) // add the value directly
as load will throw 
<br />
              
{ 
<br />
                  
if (entityReference.Value == null) 
<br />
                      
entityReference.Value = LoadByKey&lt;T&gt;(entityReference.EntityKey); 
<br />
              
} 
<br />
              
else if (entitySource.EntityState == System.Data.EntityState.Modified || entitySource.EntityState
== System.Data.EntityState.Unchanged) 
<br />
              
{ 
<br />
                  
entityReference.Load(); 
<br />
              
} 
<br />
           } 
<br />
       } 
</p>
        <blockquote>
          <p>
privateT LoadByKey&lt;T&gt;(object entityKey) 
<br />
{ 
<br />
    if (entityKey == null) 
<br />
        throw new ArgumentNullException("Supplied
entity key is null, unable to load entity", "entityKey"); 
<br />
    // make sure the object is loaded in the object context 
<br />
    ObjectContext objectContext = <font color="#ff0000">[YOUR OBJECT
CONTEXT]</font>; 
<br />
    EntityKey key = (EntityKey)entityKey; 
<br />
    ObjectStateEntry entry; 
<br />
    if (!objectContext.ObjectStateManager.TryGetObjectStateEntry(entityKey,
out entry) || entry.Entity == null) 
<br />
    { 
<br />
        return (T)objectContext.GetObjectByKey(key); 
<br />
    } 
<br />
    return (T)entry.Entity; 
<br />
}
</p>
        </blockquote>
        <p>
       /// &lt;summary&gt; 
<br />
       /// Whether or not the entity reference has an
entity key with a value present 
<br />
       /// &lt;/summary&gt; 
<br />
       public static bool HasEntityKeyFirstValue&lt;T&gt;(this
EntityReference&lt;T&gt; entityReference) where T : class, IEntityWithRelationships 
<br />
       { 
<br />
           return entityReference
!= null &amp;&amp; entityReference.EntityKey.HasFirstValue&lt;int&gt;(); 
<br />
       } 
</p>
        <p>
       /// &lt;summary&gt; 
<br />
       /// Get entity key with a value present 
<br />
       /// &lt;/summary&gt; 
<br />
       public static int GetEntityKeyFirstValue&lt;T&gt;(this
EntityReference&lt;T&gt; entityReference) where T : class, IEntityWithRelationships 
<br />
       { 
<br />
           if (entityReference !=
null) 
<br />
              
return entityReference.EntityKey.GetFirstValue&lt;int&gt;(); 
<br />
           return 0; 
<br />
       }
</p>
        <p>
 
</p>
        <p>
          <strong>EntityKey</strong>
        </p>
        <p>
 
</p>
        <p>
/// &lt;summary&gt; 
<br />
   /// Extension methods for EntityKey 
<br />
   /// &lt;/summary&gt; 
<br />
   public static class EntityKeyExtensions 
<br />
   { 
</p>
        <p>
       /// &lt;summary&gt; 
<br />
       /// Gets the first entity key value 
<br />
       /// &lt;/summary&gt; 
<br />
       /// &lt;returns&gt;the first entity key value&lt;/returns&gt; 
<br />
       public static T GetFirstValue&lt;T&gt;(this EntityKey
entityKey) 
<br />
       { 
<br />
           if (entityKey != null
&amp;&amp; entityKey.EntityKeyValues != null &amp;&amp; entityKey.EntityKeyValues.Length
&gt; 0) 
<br />
              
return (T)entityKey.EntityKeyValues.First().Value; 
<br />
           return default(T); 
<br />
       } 
</p>
        <p>
       /// &lt;summary&gt; 
<br />
       /// Sets the first entity key value 
<br />
       /// &lt;/summary&gt; 
<br />
       public static void SetFirstValue&lt;T&gt;(this
EntityKey entityKey, T value) 
<br />
       { 
<br />
           if (entityKey != null
&amp;&amp; entityKey.EntityKeyValues != null &amp;&amp; entityKey.EntityKeyValues.Length
&gt; 0) 
<br />
              
entityKey.EntityKeyValues.First().Value = value; 
<br />
           return; 
<br />
       } 
</p>
        <p>
       /// &lt;summary&gt; 
<br />
       /// Whether or not the entity key has a first
value 
<br />
       /// &lt;/summary&gt; 
<br />
       public static bool HasFirstValue&lt;T&gt;(this
EntityKey entityKey) 
<br />
       { 
<br />
           var firstValue = GetFirstValue&lt;T&gt;(entityKey); 
<br />
           var defaultValue = default(T); 
<br />
           return (!firstValue.Equals(defaultValue)); 
<br />
       }
</p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=57951fac-3b68-4330-a3f6-aa545cd85da4" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Tommy has a new bed</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/08/14/Tommy+Has+A+New+Bed.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,bf3d266c-bfc3-47c1-a3fd-eae0e07af4cb.aspx</id>
    <published>2008-08-14T12:47:57.5892500-00:00</published>
    <updated>2008-08-14T12:47:57.5892500-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <object type="application/x-shockwave-flash" width="400" height="300" data="http://www.flickr.com/apps/video/stewart.swf?v=58374" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
          <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=8b84e3d583&amp;photo_id=2762785382" />
          <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=58374" />
          <param name="bgcolor" value="#000000" />
          <param name="allowFullScreen" value="true" />
          <embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=58374" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=8b84e3d583&amp;photo_id=2762785382" height="300" width="400">
          </embed>
        </object>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=bf3d266c-bfc3-47c1-a3fd-eae0e07af4cb" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Tommy Goes on Holiday</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/08/14/Tommy+Goes+On+Holiday.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,8518836f-3437-4381-88bf-ced96baa9dc5.aspx</id>
    <published>2008-08-14T12:37:04.3392500-00:00</published>
    <updated>2008-08-14T12:40:46.2142500-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <object type="application/x-shockwave-flash" width="400" height="300" data="http://www.flickr.com/apps/video/stewart.swf?v=58374" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
          <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=6e63edaedc&amp;photo_id=2762763008&amp;show_info_box=true" />
          <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=58374" />
          <param name="bgcolor" value="#000000" />
          <param name="allowFullScreen" value="true" />
          <embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=58374" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=6e63edaedc&amp;photo_id=2762763008&amp;flickr_show_info_box=true" height="300" width="400">
          </embed>
        </object>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=8518836f-3437-4381-88bf-ced96baa9dc5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Tamaki Drive Sunset</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/08/09/Tamaki+Drive+Sunset.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,44392dfe-42ae-4b9d-9c3b-16f5ca3e8fe1.aspx</id>
    <published>2008-08-09T10:16:26.2871250-00:00</published>
    <updated>2008-08-09T10:16:26.2871250-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
All i can say is roll on spring....Probably my favouritest part of auckland is the
tamaki drive stretch out east. And sometimes you get blindingly beautiful sunsets
back across the city view. 
</p>
        <p>
          <a title="08042008231" href="http://www.flickr.com/photos/27592284@N00/2745691039/">
            <img height="547" alt="08042008231" src="http://static.flickr.com/3024/2745691039_f3676b07e9.jpg" width="729" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=44392dfe-42ae-4b9d-9c3b-16f5ca3e8fe1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Tommy gets a new bed</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/08/04/Tommy+Gets+A+New+Bed.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,9c833292-f563-447b-a2dd-9d6e18925055.aspx</id>
    <published>2008-08-04T13:34:13.5736250-00:00</published>
    <updated>2008-08-04T13:34:13.5736250-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tommy is officially a big boy now he has his own bed. He even wants to go to bed early
at the moment, not sure how long that will last though!
</p>
        <p>
 
</p>
        <p>
          <a title="02082008524" href="http://www.flickr.com/photos/27592284@N00/2732102038/">
            <img alt="02082008524" src="http://static.flickr.com/3162/2732102038_7a3118fbd0.jpg" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=9c833292-f563-447b-a2dd-9d6e18925055" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Christchurch Weekend</title>
    <link rel="alternate" type="text/html" href="http://blog.keithpatton.com/2008/07/20/Christchurch+Weekend.aspx" />
    <id>http://blog.keithpatton.com/PermaLink,guid,c33215bd-2d73-4cc1-95f4-2a1ce2e100dd.aspx</id>
    <published>2008-07-20T04:24:11.8917500-00:00</published>
    <updated>2008-07-20T04:24:11.8917500-00:00</updated>
    <category term="Life in New Zealand" label="Life in New Zealand" scheme="http://blog.keithpatton.com/CategoryView,category,Life%2Bin%2BNew%2BZealand.aspx" />
    <category term="Travel" label="Travel" scheme="http://blog.keithpatton.com/CategoryView,category,Travel.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Sorry lucy, no pictures of tommy as yet, here's some snaps of our weekend down at
christchurch/hamner springs. Will some trees do instead??
</p>
        <p>
          <a title="DSC03537" href="http://www.flickr.com/photos/27592284@N00/2684511768/">
            <img alt="DSC03537" src="http://static.flickr.com/2222/2684511768_407574a3d5.jpg" border="0" />
          </a>
          <a title="DSC03538" href="http://www.flickr.com/photos/27592284@N00/2683696635/">
            <img alt="DSC03538" src="http://static.flickr.com/3232/2683696635_f33d9a73f3.jpg" border="0" />
          </a>
          <a title="DSC03539" href="http://www.flickr.com/photos/27592284@N00/2683697485/">
            <img alt="DSC03539" src="http://static.flickr.com/3185/2683697485_ae7e0f25a3.jpg" border="0" />
          </a>
          <a title="DSC03541" href="http://www.flickr.com/photos/27592284@N00/2683697829/">
            <img alt="DSC03541" src="http://static.flickr.com/3031/2683697829_6cc01dfb9f.jpg" border="0" />
          </a>
          <a title="DSC03542" href="http://www.flickr.com/photos/27592284@N00/2684514450/">
            <img alt="DSC03542" src="http://static.flickr.com/3220/2684514450_e687959228.jpg" border="0" />
          </a>
          <a title="DSC03544" href="http://www.flickr.com/photos/27592284@N00/2684515200/">
            <img alt="DSC03544" src="http://static.flickr.com/3232/2684515200_1757ca08db.jpg" border="0" />
          </a>
          <a title="DSC03546" href="http://www.flickr.com/photos/27592284@N00/2683699589/">
            <img alt="DSC03546" src="http://static.flickr.com/3187/2683699589_a530504bbc.jpg" border="0" />
          </a>
          <a title="DSC03550" href="http://www.flickr.com/photos/27592284@N00/2683700011/">
            <img alt="DSC03550" src="http://static.flickr.com/2054/2683700011_9e864dce68.jpg" border="0" />
          </a>
          <a title="DSC03557" href="http://www.flickr.com/photos/27592284@N00/2684516548/">
            <img alt="DSC03557" src="http://static.flickr.com/3119/2684516548_3638ee3ca7.jpg" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.keithpatton.com/aggbug.ashx?id=c33215bd-2d73-4cc1-95f4-2a1ce2e100dd" />
      </div>
    </content>
  </entry>
</feed>