<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Garry Pilkington</title><link>http://weblogs.asp.net/garrypilkington/default.aspx</link><description>&lt;br/&gt;Application Developer&lt;br/&gt;Liverpool, UK</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/GarrysnetBlog" type="application/rss+xml" /><feedburner:emailServiceId>GarrysnetBlog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>Multiple Strongly Typed Partial Views in MVC</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/HksBUnOuyH4/multiple-strongly-typed-partial-views-in-mvc.aspx</link><pubDate>Tue, 20 Oct 2009 08:29:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7233628</guid><dc:creator>capgpilk</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=7233628</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=7233628</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/10/20/multiple-strongly-typed-partial-views-in-mvc.aspx#comments</comments><description>&lt;p&gt;Creating strongly typed views with the ASP.Net MVC framework is really easy, but what if you want to have multiple types on the same view? One way to achieve this is to create partial views for each type and creating a combined view model. Then the view will inherit this combined view model and each partial view will inherit from its component types.&lt;/p&gt;  &lt;p&gt;In the following simple example I have a view which itself displays two partial views. This view inherits from a type I have called CombinedViewModel.&lt;/p&gt;  &lt;p&gt;The hosting view&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum1"&gt;   &lt;/span&gt;&amp;lt;%@ Page Title=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&amp;quot;&lt;/span&gt; Language=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; MasterPageFile=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;~/Views/Shared/Site.Master&amp;quot;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum2"&gt;   &lt;/span&gt;Inherits=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;System.Web.Mvc.ViewPage&amp;lt;CombinedViewModel&amp;gt;&amp;quot;&lt;/span&gt; %&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum3"&gt;   &lt;/span&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum4"&gt;   &lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum5"&gt;  &lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum6"&gt;   &lt;/span&gt;&amp;lt;asp:Content ID=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;Content1&amp;quot;&lt;/span&gt; ContentPlaceHolderID=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;MainContent&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum7"&gt;   &lt;/span&gt;runat=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum8"&gt;   &lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum9"&gt;   &lt;/span&gt;&amp;lt;% Html.RenderPartial(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;PartialView1&amp;quot;&lt;/span&gt;, ViewData.Model.Header); %&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum10"&gt;   &lt;/span&gt;&amp;lt;% Html.RenderPartial(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;PartialView2&amp;quot;&lt;/span&gt;, ViewData.Model.Detail); %&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum11"&gt;  &lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(96,96,96)" id="lnum12"&gt;  &lt;/span&gt;&amp;lt;/asp:Content&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The controller passes the types in to the CombinedViewModel.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; ActionResult Detail(&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; id)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  Header header = DataRepository.GetHeader(id);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  List&amp;lt;Detail&amp;gt; detail = DataRepository.GetDetail(id);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  CombinedViewModel viewData = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; CombinedViewModel(header, detail);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; View(viewData);         &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The CombinedViewModel&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;class&lt;/span&gt; CombinedViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; Header  Header { get; &lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Detail&amp;gt; Detail { get; &lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; set; }  &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; JobDetailViewModel(Header header, IEnumerable&amp;lt;Detail&amp;gt; detail)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; Header = header;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; Detail= detail;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;So now each of the partial views can access the types they need.&lt;/p&gt;

&lt;p&gt;The PartialViews&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;div id="codeSnippetWrapper"&gt;
      &lt;div id="codeSnippetWrapper"&gt;
        &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;p&gt;&amp;lt;%@ Control Language=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;Inherits=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;TestApp.Models.Header&amp;gt;&amp;quot;&lt;/span&gt; %&amp;gt;&lt;/p&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;%= Model.CustomerTitle%&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;p&gt;&amp;lt;%@ Control Language=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;Inherits=&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;IEnumerable&amp;lt;TestApp.Models.Detail&amp;gt;&amp;gt;&amp;quot;&lt;/span&gt; %&amp;gt;&lt;/p&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;%= Model.OrderNumber%&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7233628" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/HksBUnOuyH4" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/MVC/default.aspx">MVC</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/10/20/multiple-strongly-typed-partial-views-in-mvc.aspx</feedburner:origLink></item><item><title>Unit Testing Videos</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/mra8r3Gm7M0/unit-testing-videos.aspx</link><pubDate>Mon, 12 Oct 2009 09:16:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7227736</guid><dc:creator>capgpilk</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=7227736</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=7227736</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/10/12/unit-testing-videos.aspx#comments</comments><description>&lt;p&gt;The &lt;a href="http://www.learnvisualstudio.net/" target="_blank"&gt;Learn Visual Studio.net&lt;/a&gt; website has just published a &lt;a href="http://www.learnvisualstudio.net/content/series/Unit_Testing_401.aspx" target="_blank"&gt;new series on unit testing&lt;/a&gt;, covering an introduction to unit testing, using MSTest, and NUnit. These are always good sources of practical information to help you get up to speed on anything .net. Go check them out.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7227736" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/mra8r3Gm7M0" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/General+stuff/default.aspx">General stuff</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/10/12/unit-testing-videos.aspx</feedburner:origLink></item><item><title>TempData and DropDownList in ASP.Net MVC</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/hirTSZL-60U/tempdata-and-dropdownlist-in-asp-net-mvc.aspx</link><pubDate>Tue, 29 Sep 2009 10:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7219853</guid><dc:creator>capgpilk</dc:creator><slash:comments>6</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=7219853</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=7219853</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/09/29/tempdata-and-dropdownlist-in-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;&lt;b&gt;TempData&lt;/b&gt;     &lt;br&gt;    &lt;br&gt;Sometimes while developing web applications, you have a need to keep certain data between web requests. In asp.Net MVC you can use TempData which will keep hold of any values you pass to it for that request and the next request when it is then removed. This is a great way of keeping form elements at a particular state during form submission from an mvc view. In the following example I will briefly explain how to render a drop down list populated with data which will keep the selected value across form submission.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The ActionResult&lt;/b&gt;     &lt;br&gt;    &lt;br&gt;In the ActionResult in the controller for the view you get the value of the drop down selected item which is held in the FormCollection. Then simply call a method that returns a IList&amp;lt;SelectListItem&amp;gt; collection, passing in the selected item. The resulting collection is then passed to a TempDataDictionary which is in turn passed back to the view.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;     &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; ActionResult DistrictsView(FormCollection collection)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum3"&gt;   3:&lt;/span&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; selectedValue = Convert.ToInt32(collection[&lt;span style="color: rgb(0, 96, 128);"&gt;"Districts"&lt;/span&gt;]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum4"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum5"&gt;   5:&lt;/span&gt;   TempData[&lt;span style="color: rgb(0, 96, 128);"&gt;"Districts"&lt;/span&gt;] = DropDownPopulators.GetDistricts(selectedValue);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum6"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum7"&gt;   7:&lt;/span&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; View();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum8"&gt;   8:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum9"&gt;   9:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Keeping the selected value 
    &lt;br&gt;

    &lt;br&gt;&lt;/b&gt;The drop down list takes a collection of SelectlistItems in the form of text/value pairs. What the following method does is generate a dictionary collection of districts and the associated key, then creates the IList&amp;lt;SelectListItem&amp;gt; for the drop down, but it also sets the selected property to true for the selected value passed in from the view. The GetDistrictList method call simply returns a dictionary collection from the database of district and integer values.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;
    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; IList&amp;lt;SelectListItem&amp;gt; GetDistricts(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; selectedValue)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum3"&gt;   3:&lt;/span&gt;   IList&amp;lt;SelectListItem&amp;gt; districts = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; List&amp;lt;SelectListItem&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum4"&gt;   4:&lt;/span&gt;   Dictionary&amp;lt;&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&amp;gt; districtCollection &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum5"&gt;   5:&lt;/span&gt;    = DataRepository.GetDistrictList();  &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum6"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum7"&gt;   7:&lt;/span&gt;   SelectListItem itemAll = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; SelectListItem();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum8"&gt;   8:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum9"&gt;   9:&lt;/span&gt;   itemAll.Value = &lt;span style="color: rgb(0, 96, 128);"&gt;"0"&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum10"&gt;  10:&lt;/span&gt;   itemAll.Text = &lt;span style="color: rgb(0, 96, 128);"&gt;"All"&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum11"&gt;  11:&lt;/span&gt;   districts.Add(itemAll);   &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum12"&gt;  12:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum13"&gt;  13:&lt;/span&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; dist &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; districtCollection)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum14"&gt;  14:&lt;/span&gt;   {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum15"&gt;  15:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (dist.Key == selectedValue)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum16"&gt;  16:&lt;/span&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum17"&gt;  17:&lt;/span&gt;     SelectListItem item = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; SelectListItem();  &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum18"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum19"&gt;  19:&lt;/span&gt;     item.Value = dist.Key.ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum20"&gt;  20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum21"&gt;  21:&lt;/span&gt;     item.Text = dist.Value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum22"&gt;  22:&lt;/span&gt;     item.Selected = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum23"&gt;  23:&lt;/span&gt;     districts.Add(item);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum24"&gt;  24:&lt;/span&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum25"&gt;  25:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum26"&gt;  26:&lt;/span&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum27"&gt;  27:&lt;/span&gt;     SelectListItem item = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; SelectListItem();  &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum28"&gt;  28:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum29"&gt;  29:&lt;/span&gt;     item.Value = dist.Key.ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum30"&gt;  30:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum31"&gt;  31:&lt;/span&gt;     item.Text = dist.Value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum32"&gt;  32:&lt;/span&gt;     item.Selected = &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum33"&gt;  33:&lt;/span&gt;     districts.Add(item);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum34"&gt;  34:&lt;/span&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum35"&gt;  35:&lt;/span&gt;   }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum36"&gt;  36:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; districts;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum37"&gt;  37:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Displaying the DropDownList in a view&lt;/b&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;
    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum1"&gt;   1:&lt;/span&gt; &amp;lt;%=Html.DropDownList(&lt;span style="color: rgb(0, 96, 128);"&gt;"Districts"&lt;/span&gt;, TempData[&lt;span style="color: rgb(0, 96, 128);"&gt;"Districts"&lt;/span&gt;] &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;as&lt;/span&gt; List&amp;lt;SelectListItem&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum3"&gt;   3:&lt;/span&gt;  , &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; { &lt;span style="color: rgb(204, 102, 51);"&gt;@onchange&lt;/span&gt; = &lt;span style="color: rgb(0, 96, 128);"&gt;"this.form.submit();"&lt;/span&gt; })%&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This binds the Districts TempData to the DropDownList helper in the view. The clever bit here is the creation of the form submit java script when the drop down is changed.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7219853" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/hirTSZL-60U" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/MVC/default.aspx">MVC</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/09/29/tempdata-and-dropdownlist-in-asp-net-mvc.aspx</feedburner:origLink></item><item><title>Code Snippet Plugin for Live Writer</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/X0UCDV1YZg0/code-snippet-plugin-for-live-writer.aspx</link><pubDate>Tue, 29 Sep 2009 08:27:13 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7219805</guid><dc:creator>capgpilk</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=7219805</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=7219805</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/09/29/code-snippet-plugin-for-live-writer.aspx#comments</comments><description>&lt;p&gt;For anybody who regularly displays code using Live Writer, then this plugin by Leo Vildosola is a must to check out. When ever I do a rebuild of any of my computers this has to go on and I always have trouble remembering where I found it. &lt;/p&gt;  &lt;p&gt;So here are a couple of links.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lvildosola.blogspot.com/" target="_blank"&gt;Leo Vilosola’s blog&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://wlwplugincollection.codeplex.com/Wiki/View.aspx?title=Code%20Snippet" target="_blank"&gt;Plugin site at codeplex&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7219805" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/X0UCDV1YZg0" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/General+stuff/default.aspx">General stuff</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Tools/default.aspx">Tools</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/09/29/code-snippet-plugin-for-live-writer.aspx</feedburner:origLink></item><item><title>LINQ Projection</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/OEf2M6IWnlo/linq-projection.aspx</link><pubDate>Tue, 08 Sep 2009 09:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7195850</guid><dc:creator>capgpilk</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=7195850</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=7195850</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/09/08/linq-projection.aspx#comments</comments><description>&lt;p&gt;just recently I have been doing quite a bit of work with LINQ and L2S in particular. Although LINQ is nothing new now and I am sure the vast majority of readers out there have had some form of introduction to LINQ. However one of the great things that I still find fascinating is a technique called projection. This is a way to shape data coming back from a query into something more akin to what you want.&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left; max-height: 200px"&gt;   &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; class User&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     public string UserFullName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     public double HoursWorked { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt; class Program&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;     static void Main()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;         List&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;User&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt; users = new List&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;User&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;         users.Add(new User { HoursWorked = 12.5d, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;             UserFullName = &amp;quot;Ann Admin&amp;quot; });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;         users.Add(new User { HoursWorked = 6.5d, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;             UserFullName = &amp;quot;Test User&amp;quot; });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt;         users.Add(new User { HoursWorked = 8.5d, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt;             UserFullName = &amp;quot;Test User&amp;quot; });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt;         users.Add(new User { HoursWorked = 3.5d, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt;             UserFullName = &amp;quot;Test User&amp;quot; });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt;         var q = from user in users&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt;                 where user.UserFullName.Equals(&amp;quot;Test User&amp;quot;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;                 select new&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;                  {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;                      user.UserFullName,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;                      user.HoursWorked,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;                      HoursRemaining = (8.5 - user.HoursWorked)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;                  };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;         foreach (var list in q)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;             Console.WriteLine(list.UserFullName + &amp;quot; - &amp;quot;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;                 + list.HoursWorked&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;                 + &amp;quot;(&amp;quot; + list.HoursRemaining + &amp;quot;)&amp;quot;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum38" style="color: #606060"&gt;  38:&lt;/span&gt;         Console.Read();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum39" style="color: #606060"&gt;  39:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum40" style="color: #606060"&gt;  40:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Here the query is creating a new type with three fields. This is especially useful if like above you are doing some form of calculation which you want to use, but is not represented anywhere in the data model.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7195850" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/OEf2M6IWnlo" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/linq/default.aspx">linq</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/09/08/linq-projection.aspx</feedburner:origLink></item><item><title>Complex Types in the Entity Framework</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/qgfoEeoc0VM/complex-types-in-the-entity-framework.aspx</link><pubDate>Mon, 31 Aug 2009 15:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7186543</guid><dc:creator>capgpilk</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=7186543</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=7186543</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/08/31/complex-types-in-the-entity-framework.aspx#comments</comments><description>&lt;p&gt;In this post I will describe the process you need to go through to get a stored procedure to return a complex type in the Entity Framework.&lt;/p&gt;  &lt;p&gt;It is very easy in the Entity Framework to quickly create crud functions that will manipulate data in your tables. However if you want to use stored procedures that return data that is not mapped to an entity from your database, then there are a few more hoops you need to jump through.&lt;/p&gt;  &lt;p&gt;Firstly, by examining the stored procedure, you can determine what data types are returned from the stored procedure. &lt;/p&gt;  &lt;p&gt;This following method is a quick and dirty one I have used, there may be a better way to do this, and if there is please let me know. There is a tool called &lt;a href="http://www.devart.com/entitydeveloper/" target="_blank"&gt;Entity Developer from devart&lt;/a&gt; which may do the same, but as yet I haven’t had the chance to use it.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Switch to your *.edmx file and drop a new entity from the toolbox on to the design surface. You may need to delete the Id property that is automatically created if you don’t need it.     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/2_7C7C1592.jpg"&gt;&lt;img title="2" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="137" alt="2" src="http://weblogs.asp.net/blogs/garrypilkington/2_thumb_79D5EA92.jpg" width="178" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Then right click on any of the entries in the model browser and choose ‘Update Model From Database’     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/1_5714B2D5.jpg"&gt;&lt;img title="1" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="139" alt="1" src="http://weblogs.asp.net/blogs/garrypilkington/1_thumb_14386E5B.jpg" width="382" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Choose any tables that your procedure uses from the Add tab. This will map the tables as entities, allowing you to simply copy and paste entity properties from the tables into your new entity.&lt;/li&gt;    &lt;li&gt;Add your stored procedure.&lt;/li&gt;    &lt;li&gt;Right click on ‘Function Imports’ within the Entity Container in the Model Browser and choose ‘Create Function Import’.     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/3_61D72B8C.jpg"&gt;&lt;img title="3" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="146" alt="3" src="http://weblogs.asp.net/blogs/garrypilkington/3_thumb_1EFAE712.jpg" width="348" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;This then gives you the options to Choose the stored procedure, its name and most importantly the Entity that it will be imported to. Choose your new entity you have just created.     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/4_10BEFED3.jpg"&gt;&lt;img title="4" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="238" alt="4" src="http://weblogs.asp.net/blogs/garrypilkington/4_thumb_1B12B3E4.jpg" width="328" border="0" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Now your new entity can be called&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left; max-height: 200px"&gt;   &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; ProjectMVCEntities myEntities = new ProjectMVCEntities();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt;                 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt; var viewData = myEntities.Job(0, 4).ToList();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;         &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; return View();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This is taken from an MVC project, hence the return value of View(), but I hope you get the idea.&lt;/p&gt;

&lt;p&gt;Now the stored procedure will be executed with any required parameters and the Job entity will hold the data.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7186543" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/qgfoEeoc0VM" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/08/31/complex-types-in-the-entity-framework.aspx</feedburner:origLink></item><item><title>LINQ to XML Quick Brain Dump</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/FOmaEbVp-ZY/linq-to-xml-quick-brain-dump.aspx</link><pubDate>Tue, 25 Aug 2009 20:10:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7181257</guid><dc:creator>capgpilk</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=7181257</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=7181257</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/08/25/linq-to-xml-quick-brain-dump.aspx#comments</comments><description>&lt;p&gt;LINQ to XML is a simple toolset that allows developers to easily interact with XML, whether it be in file form of on the wire in string form.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Write to an XML file&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;There are a few methods within the System.Xml.Linq namespace which make this interaction a breeze. The four main ones are:-&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;XDocument – Method which creates the XML document&lt;/li&gt;    &lt;li&gt;XDeclaration – Allows you to set the declaration at the top of the file.&lt;/li&gt;    &lt;li&gt;XElement – Creates a hierarchical element structure&lt;/li&gt;    &lt;li&gt;XAttribute – Creates any attributes related to an element.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The following code shows a very simple way to generate an XML document for members of a club.&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left; max-height: 200px;"&gt;   &lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;     &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; Member[] members = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;[] {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Member{Age = 33, FullName = &lt;span style="color: rgb(0, 96, 128);"&gt;"John Havers"&lt;/span&gt;, Title = &lt;span style="color: rgb(0, 96, 128);"&gt;"Mr"&lt;/span&gt;},&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Member{Age = 28, FullName = &lt;span style="color: rgb(0, 96, 128);"&gt;"Robin Southgate"&lt;/span&gt;, Title = &lt;span style="color: rgb(0, 96, 128);"&gt;"Mrs"&lt;/span&gt;},&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Member{Age = 45, FullName = &lt;span style="color: rgb(0, 96, 128);"&gt;"Paul Chatwell"&lt;/span&gt;, Title = &lt;span style="color: rgb(0, 96, 128);"&gt;"Mr"&lt;/span&gt;},&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt; XDocument doc = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; XDocument(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; XDeclaration(&lt;span style="color: rgb(0, 96, 128);"&gt;"1.0"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"utf-8"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"yes"&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;           &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; XElement(&lt;span style="color: rgb(0, 96, 128);"&gt;"members"&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;           from member &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; members&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;           select &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; XElement(&lt;span style="color: rgb(0, 96, 128);"&gt;"member"&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;                  &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; XAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"age"&lt;/span&gt;, member.Age),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;                  &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; XAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"title"&lt;/span&gt;, member.Title),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;                  &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; XElement(&lt;span style="color: rgb(0, 96, 128);"&gt;"fullname"&lt;/span&gt;, member.FullName)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;         )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;     )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt; );&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;         doc.Save(&lt;span style="color: rgb(0, 96, 128);"&gt;@"c:\members.xml"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This would generate this XML file.&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left; max-height: 200px;"&gt;
  &lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;
    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xml&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;version&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1.0"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;encoding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="utf-8"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;standalone&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="yes"&lt;/span&gt; ?&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;members&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;member&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;age&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="33"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Mr"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;fullname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;John Havers&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;fullname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;member&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;age&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="28"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Mrs"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;fullname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;Robin Southgate&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;fullname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;member&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;age&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="45"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Mr"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;fullname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;Paul Chatwell&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;fullname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;members&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Reading from an XML file&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Firstly use the Load method of the XDocument class, then a simple LINQ query will return all elements within the root element like this.&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left; max-height: 200px;"&gt;
  &lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;
    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; IEnumerable&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;XElement&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt; q = from c in loaded.Root.Elements("member")&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;                                   select c;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;         foreach (XElement element in q)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;             foreach (XElement r in element.Elements())&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;                 Console.WriteLine(r.Value);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: white; text-align: left;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This query lists all the elements called ‘member’ within the root. Then for each member element it will again for each through for any elements within those. In our example the members full name is located there, so a simple value output will write the data to the console.&lt;/p&gt;

&lt;p&gt;You can still use var for the query, but during running of the code it is possible to determine the resultant type.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/debug_2CA50182.jpg" mce_href="http://weblogs.asp.net/blogs/garrypilkington/debug_2CA50182.jpg"&gt;&lt;img src="http://weblogs.asp.net/blogs/garrypilkington/debug_thumb_40C0AEBC.jpg" title="debug" style="border: 0px none ; display: inline;" alt="debug" mce_src="http://weblogs.asp.net/blogs/garrypilkington/debug_thumb_40C0AEBC.jpg" width="496" border="0" height="174"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This shows that it is of type&amp;nbsp; XElement and that it is enumerable so you can change var to IENumerable&amp;lt;XElement&amp;gt; to give the code more meaning.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7181257" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/FOmaEbVp-ZY" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/linq/default.aspx">linq</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/08/25/linq-to-xml-quick-brain-dump.aspx</feedburner:origLink></item><item><title>Do you test your private methods?</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/ZAoXhPussMA/do-you-test-your-private-methods.aspx</link><pubDate>Wed, 18 Feb 2009 11:44:37 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6914559</guid><dc:creator>capgpilk</dc:creator><slash:comments>7</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6914559</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6914559</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/02/18/do-you-test-your-private-methods.aspx#comments</comments><description>&lt;p&gt;There is ample discussion on the blogosphere as to why you should or shouldn't test your private methods.&amp;#160; &lt;/p&gt;  &lt;p&gt;In the 'NO camp'&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.redhillconsulting.com.au/blogs/simon/archives/000119.html"&gt;http://www.redhillconsulting.com.au/blogs/simon/archives/000119.html&lt;/a&gt;, &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/11/21/do-not-test-private-methods.aspx"&gt;http://www.lostechies.com/blogs/chad_myers/archive/2008/11/21/do-not-test-private-methods.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In the 'YES camp'&lt;/p&gt;  &lt;p&gt;&lt;a href="http://beust.com/weblog/archives/000303.html"&gt;http://beust.com/weblog/archives/000303.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I think there is some confusion as to why you should or shouldn’t.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Test-Driven Development&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you personally are practicing TDD then you are testing a whole chunk of code before and after refactoring. If your code passes the tests before refactoring, then you can be sure that any extracted methods are covered. That is to say you don’t &lt;strong&gt;need&lt;/strong&gt; to test these methods (private or public) as their containing code have tests already. &lt;/p&gt;  &lt;p&gt;Ok so you write your test, it fails. You then write your code to make the test pass. You are green. Then you refractor. After you refractor, you realize the method can be made private as nothing outside the class needs to know it is there. So now you have a private without any immediately related test (even though it is actually covered with the pre-refractored test). &lt;/p&gt;  &lt;p&gt;Now if at some point in the future another developer comes along and adds a private method without any associated test; you now have two private methods, one with a test, one without. A quick glance at the source code of the test suite may not show that the first private method is covered. Perhaps forcing a rule that &lt;strong&gt;all&lt;/strong&gt; methods should be tested should eliminate those non tested methods from creeping in. It may be a case of refactoring your tests to make sure each method has at least one associated test.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Regression testing&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you are working with legacy code and you are required to make changes to some public or even private methods, it would be wise to wrap tests around these methods, that way you can be sure they are functioning the same after the changes as they were before. This would be the same case for both public and private.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Code Coverage&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Code coverage is the extent to which code has been tested; that is &lt;strong&gt;all&lt;/strong&gt; code. So if you have 2 public methods and 98 private methods (just for example, this would be a ridiculously large class) and you have tests only for the public methods and not the private ones; do you have 100% code coverage? I wouldn't say so. I wouldn't be confident with a situation where I don't have any coverage of private methods.&lt;/p&gt;  &lt;p&gt;I like the quote from&amp;#160; Cedric Beust post.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;quot;if it can break, test it&amp;quot;&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6914559" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/ZAoXhPussMA" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/02/18/do-you-test-your-private-methods.aspx</feedburner:origLink></item><item><title>Why I prefer c# over VB</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/deP1L6eZzgg/why-i-prefer-c-over-vb.aspx</link><pubDate>Wed, 11 Feb 2009 13:52:02 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6897734</guid><dc:creator>capgpilk</dc:creator><slash:comments>10</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6897734</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6897734</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/02/11/why-i-prefer-c-over-vb.aspx#comments</comments><description>&lt;p&gt;A couple of weeks back I was asked by a friend of a friend why I code in c# over VB. I didn’t give him a very good answer at the time as I just couldn’t pinpoint the reason. Since then I have had a real good think about it and have come to this conclusion. It just looks bulky. Not a good reason I know. I am not what you would consider a power developer, I use .net for relatively simple tasks and there isn’t any feature I would consider using one language over the other. So for me it just comes down to aesthetics. I can and have programmed in both classic VB and VB.Net and it was only about 4 years ago that I decided to have a look at c#. Now when I look at old code I have written in VB.Net I not only shudder at the overall crapness of my code, but also the amount of non-whitespace. A simple while loop in VB looks less clean than its cousin in c#.&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; Dim counter As Integer = 0&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; While counter &amp;lt; 20&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     counter += 1&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; End While&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; counter = 0;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;while&lt;/span&gt; (counter &amp;lt; 20) &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;       {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;          counter++;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;       }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;For me the second code example is easier to read, I know the while construct has ended by the placement of the closing brace I don’t need 8 superfluous characters to tell me that.&lt;/p&gt;

&lt;p&gt;I was brought up with BASIC on the Commodore 64 and then Amiga BASIC through vb2,3,4,5 (didn’t really use vb6), then VB.Net and now c#. I do feel to a certain extent a bit of a traitor.&lt;/p&gt;

&lt;p&gt;As has been reported elsewhere, word is that inside Microsoft they are trying to align the language development teams more so a particular feature that becomes available for one language will immediately be available in others. Will this blur the choice between languages?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6897734" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/deP1L6eZzgg" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/VB.Net/default.aspx">VB.Net</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/02/11/why-i-prefer-c-over-vb.aspx</feedburner:origLink></item><item><title>Quickly reading technical articles and books</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/J3b9612KxIw/quickly-reading-technical-articles-and-books.aspx</link><pubDate>Wed, 04 Feb 2009 11:11:05 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6881021</guid><dc:creator>capgpilk</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6881021</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6881021</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/02/04/quickly-reading-technical-articles-and-books.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/Picture%20005_28C26E06.jpg"&gt;&lt;img title="Picture 005" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 15px 15px; border-right-width: 0px" height="153" alt="Picture 005" src="http://weblogs.asp.net/blogs/garrypilkington/Picture%20005_thumb_6D056603.jpg" width="203" align="right" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;There is so much information out there pertaining to our jobs, a lot comes in the form of articles and books. How do you get through all this information fast without loosing comprehension? &lt;/p&gt;  &lt;p&gt;Well this is my technique. I have used this since my university days, and although it works for me, it isn’t perfect for everyone. It is a mixture of &lt;a href="http://en.wikipedia.org/wiki/Speed_Reading" target="_blank"&gt;speed reading&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Mind_Map" target="_blank"&gt;mind mapping&lt;/a&gt;. I use this for both technical articles such as research papers as well as chapters from technical books.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Quickly skim the paper or chapter noting down only the subheadings. &lt;/li&gt;    &lt;li&gt;Use these subheadings as the main section of a mind map branching out from a central topic. This central topic could be paper or chapter title. &lt;/li&gt;    &lt;li&gt;Look at and normally read the captions for any diagrams and charts (not source code though) &lt;/li&gt;    &lt;li&gt;Speed read the article or chapter, don’t stop for words or phrases you don’t quite understand. &lt;/li&gt;    &lt;li&gt;Speed read the article again, this time writing out any key points under their relevant topics on the mind map. &lt;/li&gt;    &lt;li&gt;Go have a cup of coffee. &lt;/li&gt;    &lt;li&gt;Look over your mind map. You will naturally be drawn to topic areas that interest you the most. If needed you could re-read these sections again. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;There are several ideas behind this technique.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Getting your brain to absorb only information that interests it. Most text from books and published papers are written in such a way that allows the reader to easily flow between the related subject matter within it. &lt;/li&gt;    &lt;li&gt;You look at images and charts before starting to read so as to give yourself a heads up for when you reach that section of the text. &lt;/li&gt;    &lt;li&gt;Not stopping for difficult phrases or words helps keep the rhythm up, you will be covering these words again at the second pass. Second time around you will have more of an idea of the context of the piece. &lt;/li&gt;    &lt;li&gt;The detail of the mind map automatically comes out from the subject matter that interests you. We all have a tendency to remember information that is of interest to us. This information can also give extra pointers for more research down different paths. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So the speed reading gets you through the text fast and the mind map emphasizes the important bits.&lt;/p&gt;  &lt;p&gt;The main difficulty with speed reading I find is keeping it up. Initially it is so easy to drop back into normal ‘speaking in your head’ reading. Keep practicing, it will get easier.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;What about code?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The only way I find to understand the code aspect of these articles is to just type it in and step through using the debugger. I find learning easier if I can do some practical work to go along with the theory. Does anybody else have any tips?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6881021" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/J3b9612KxIw" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/General+stuff/default.aspx">General stuff</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Tools/default.aspx">Tools</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/02/04/quickly-reading-technical-articles-and-books.aspx</feedburner:origLink></item><item><title>Open containing folder</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/rYOQhzNYWtg/open-containing-folder.aspx</link><pubDate>Fri, 16 Jan 2009 10:34:07 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6838727</guid><dc:creator>capgpilk</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6838727</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6838727</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/01/16/open-containing-folder.aspx#comments</comments><description>&lt;p&gt;This is one VS 2008 shortcut I use all the time. Open the folder which contains the file you are currently working on. &lt;/p&gt;  &lt;p&gt;Simply right click the tab in the editor view and choose that option. Ok nothing new there. It would be better if there was a shortcut. Go to Tools &amp;gt; Options &amp;gt; Keyboard and select File.OpenContainingFolder and assign a key, I chose Alt+o. Really simple, never got around to assigning it until now.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6838727" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/rYOQhzNYWtg" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/General+stuff/default.aspx">General stuff</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Tools/default.aspx">Tools</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/01/16/open-containing-folder.aspx</feedburner:origLink></item><item><title>Objectives 2009</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/PJk1G8jgWMU/objectives-2009.aspx</link><pubDate>Tue, 06 Jan 2009 11:22:36 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6822443</guid><dc:creator>capgpilk</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6822443</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6822443</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2009/01/06/objectives-2009.aspx#comments</comments><description>&lt;p&gt;I am a little late in setting out my resolutions, and although 1st January is a good time of year to set out your objectives, I’ve never liked to be restricted by a date. If I smoked (which I don’t), and I wanted to give it up, I wouldn’t wait until the 1st Jan, I would give up there and then. No time like the present. So last February I set out some objectives for the coming 6 months, how did I do?&lt;/p&gt;  &lt;p&gt;1. Finish my MCSE Upgrade exams – done   &lt;br /&gt;2. Get to grips with the latest development methodologies such as Inversion of Control, Design Patterns, Mocking, Unit testing, MVC and MVP, Dependency Injection, and Continuous Integration – well I got to grips with Unit testing, Continuous Integration and MVC, I started with the other design patterns then ground to a halt.    &lt;br /&gt;3. Get all my code to pass FxCop analysis – done&lt;/p&gt;  &lt;p&gt;So what for the next 6 months?&lt;/p&gt;  &lt;p&gt;1. Getting to grips with Design Patterns.   &lt;br /&gt;2. Look into the Entity Framework as compared to other tools already out there.    &lt;br /&gt;3. Look into Ioc/ Dependency Injection frameworks.&lt;/p&gt;  &lt;p&gt;I think I will tackle these in this order as I have already started on design patterns.&lt;/p&gt;  &lt;p&gt;There are of course smaller ongoing objectives which I aim to have a go at, some of these are:-&lt;/p&gt;  &lt;p&gt;1. Learn how to get more out of Resharper. I find this an invaluable tool and I know there is more to it that what I use it for, so I plan on utilizing it more.   &lt;br /&gt;2. Build the analysis results from FxCop, StyleCop and perhaps SourceMonitor into our CI environment&lt;/p&gt;  &lt;p&gt;You may be asking ‘why am I blogging this?’. Well to be honest I find it difficult to remain focused on a particular objective and some times need a quick reminder.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6822443" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/PJk1G8jgWMU" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Inversion+of+Control/default.aspx">Inversion of Control</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Dependency+Injection/default.aspx">Dependency Injection</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Continuous+Integration/default.aspx">Continuous Integration</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/General+stuff/default.aspx">General stuff</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Patterns/default.aspx">Patterns</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2009/01/06/objectives-2009.aspx</feedburner:origLink></item><item><title>My end of year tool honours list</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/8tuR_LgekCU/my-end-of-year-tool-honours-list.aspx</link><pubDate>Wed, 24 Dec 2008 12:06:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6805957</guid><dc:creator>capgpilk</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6805957</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6805957</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2008/12/24/my-end-of-year-tool-honours-list.aspx#comments</comments><description>&lt;p&gt;Well the holiday season is finally upon us, and I would like to take this opportunity to post a list of applications that I personally have found useful over the past 12 months. There are some classics in there, but a few surprises. Have a look, there may be something of interest to you. So, have yourself a ‘Merry Christmas and a Happy New Year’.&lt;/p&gt;  &lt;p&gt;Windows Server 2008 (&lt;a href="http://www.win2008workstation.com/wordpress/" target="_blank"&gt;configured as a workstation&lt;/a&gt;)     &lt;br /&gt;Visual Studio 2008     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Plug-ins – &lt;a href="http://www.roland-weigelt.de/ghostdoc/" target="_blank"&gt;Ghost Doc&lt;/a&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://www.jetbrains.com/resharper/" target="_blank"&gt;Resharper 4.1&lt;/a&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/" target="_blank"&gt;Copy Source as HTML&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Firefox    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Plug-ins – &lt;a href="http://www.foxmarks.com/" target="_blank"&gt;Foxmarks&lt;/a&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/77" target="_blank"&gt;Sage RSS&lt;/a&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1843" target="_blank"&gt;Firebug&lt;/a&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://www.colorzilla.com/firefox/" target="_blank"&gt;Colorzilla&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://widgets.yahoo.com/" target="_blank"&gt;Yahoo Widgets&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;General Tools    &lt;br /&gt;&lt;a href="http://www.deepburner.com" target="_blank"&gt;Deep Burner&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.foxitsoftware.com/pdf/rd_intro.php" target="_blank"&gt;Foxit Reader&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.magiciso.com" target="_blank"&gt;Magic ISO&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.glaryutilities.com" target="_blank"&gt;Glary Utilities&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.ccleaner.com" target="_blank"&gt;CCleaner&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://windirstat.info/" target="_blank"&gt;Win dirstat&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://notepad-plus.sourceforge.net" target="_blank"&gt;Notepad++&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://kessels.nl/JkDefrag/index.html" target="_blank"&gt;JKDefrag&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Continuous Integration    &lt;br /&gt;&lt;a href="http://ccnet.thoughtworks.com" target="_blank"&gt;CC.Net&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.nunit.org/index.php" target="_blank"&gt;NUnit&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://nant.sourceforge.net/" target="_blank"&gt;NAnt&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.download.com/Editor4NAnt/3000-2352_4-10531916.html" target="_blank"&gt;Editor4NAnt&lt;/a&gt;&amp;#160; &lt;br /&gt;&lt;a href="http://www.ncover.com/" target="_blank"&gt;NCover&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Code Analysis &amp;amp; restructuring    &lt;br /&gt;&lt;a href="http://www.ndepend.com/" target="_blank"&gt;NDepend&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://narrange.sourceforge.net/" target="_blank"&gt;NArrange&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://winmerge.org" target="_blank"&gt;Win Merge&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.red-gate.com/products/reflector" target="_blank"&gt;Reflector&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.campwoodsw.com/sourcemonitor.html" target="_blank"&gt;Source Monitor&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;Documentation generation     &lt;br /&gt;&lt;a href="http://blogs.msdn.com/sandcastle/" target="_blank"&gt;Sandcastle&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.codeplex.com/SHFB" target="_blank"&gt;Sandcastle Help File Builder&lt;/a&gt;&amp;#160; &lt;br /&gt;    &lt;br /&gt;XML     &lt;br /&gt;&lt;a href="http://pgfearo.googlepages.com/" target="_blank"&gt;SketchPath&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Source control    &lt;br /&gt;&lt;a href="http://subversion.tigris.org" target="_blank"&gt;Subversion&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tortoisesvn.tigris.org" target="_blank"&gt;Tortoise SVN&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://ankhsvn.open.collab.net" target="_blank"&gt;Ankh SVN&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Graphics    &lt;br /&gt;&lt;a href="http://www.paint.net" target="_blank"&gt;Paint.Net&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Blogging    &lt;br /&gt;&lt;a href="http://windowslivewriter.spaces.live.com" target="_blank"&gt;Live Writer&lt;/a&gt; (of course :)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Plug-ins – &lt;a href="http://lvildosola.blogspot.com/2007/02/code-snippet-plugin-for-windows-live.html" target="_blank"&gt;Code Snippet plug-in&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6805957" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/8tuR_LgekCU" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Refactoring/default.aspx">Refactoring</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/NAnt/default.aspx">NAnt</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Continuous+Integration/default.aspx">Continuous Integration</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/CruiseControl.Net/default.aspx">CruiseControl.Net</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/General+stuff/default.aspx">General stuff</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Tools/default.aspx">Tools</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/SubSonic/default.aspx">SubSonic</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2008/12/24/my-end-of-year-tool-honours-list.aspx</feedburner:origLink></item><item><title>Integrate NCover with CC.Net</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/4db4bdEpx7M/integrate-ncover-with-cc-net.aspx</link><pubDate>Thu, 11 Dec 2008 16:42:52 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6778353</guid><dc:creator>capgpilk</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6778353</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6778353</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2008/12/11/integrate-ncover-with-cc-net.aspx#comments</comments><description>&lt;p&gt;In previous posts I have covered getting &lt;a href="http://weblogs.asp.net/garrypilkington/archive/2008/04/03/ccnet-up-and-running.aspx" target="_blank"&gt;cc.net up and running&lt;/a&gt;, &lt;a href="http://weblogs.asp.net/garrypilkington/archive/2008/07/11/cc-net-and-nunit-play-nice-together.aspx" target="_blank"&gt;combining NUnit reports with cc.net&lt;/a&gt; and &lt;a href="http://weblogs.asp.net/garrypilkington/archive/2008/10/09/auto-generating-help-with-nant-and-cc-net.aspx" target="_blank"&gt;generating documentation automatically as part of the build process&lt;/a&gt;. In this post I want to briefly describe how to get your unit test code coverage integrated with cc.net.&lt;/p&gt;  &lt;p&gt;If like me you have a legacy project that you think has been tested to the ends of the Earth and back, you may be in for a shock. There will be sections of your code base that is just not touched by your unit tests. One of the best tools to see where you are missing coverage is NCover. This is a tool which although was once free, you can still get fully functional free versions prior to the project becoming commercialised. These can be &lt;a href="http://www.ncover.com/download/discontinued" target="_blank"&gt;downloaded from here&lt;/a&gt;. Version 1.5.8 is the one I have been using here. Although it states it is beta, it is fully functional and as far as I can tell, bug free.&lt;/p&gt;  &lt;p&gt;There is another tool you may need, although it doesn’t effect our usage with cc.net. This tool is NCover explorer, and like NCover used to be a free product. It is now shipped with the full NCover. Older versions of NCover explorer can be downloaded from &lt;a href="http://www.kiwidude.com/dotnet/DownloadPage.html" target="_blank"&gt;Grant Drakes blog here&lt;/a&gt;. I have been using version 1.4.0.7.&lt;/p&gt;  &lt;p&gt;There are two methods to you using NCover. The first is to attach it to your application and run it. It will analyze all the sections of code which it touches and those it doesn’t touch at all. This is ok if you just want to see if there are any code which is being underused or parts which are overused and could be a potential bottleneck. The second method is to run it against the dll produced from your unit tests. This is the method I will describe as it shows how much coverage your tests give as opposed to how much code the application covers. Don’t be confused all we be clear in a moment.&lt;/p&gt;  &lt;p&gt;OK, firstly you need to make sure that your unit tests are compiled to a dll, you can use a Nant script for this. Here is an example of one of my NAnt scripts.&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &amp;lt;csc target=&lt;span style="color: #006080"&gt;&amp;quot;library&amp;quot;&lt;/span&gt; output=&lt;span style="color: #006080"&gt;&amp;quot;nant_build\UnitTests.dll&amp;quot;&lt;/span&gt; debug=&lt;span style="color: #006080"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;       &amp;lt;sources&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;         &amp;lt;include name=&lt;span style="color: #006080"&gt;&amp;quot;..\UnitTests\*.cs&amp;quot;&lt;/span&gt;/&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;       &amp;lt;/sources&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;       &amp;lt;references&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &amp;lt;include name=&lt;span style="color: #006080"&gt;&amp;quot;nant_build\MyApp.dll&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &amp;lt;include name=&lt;span style="color: #006080"&gt;&amp;quot;nant_build\nunit.framework.dll&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;       &amp;lt;/references&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     &amp;lt;/csc&amp;gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Without posting the whole script, firstly MyApp is compiled into the nant_build directory, then the above section compiles just the unit tests which are in a separate project in the same solution. One important thing to note is the fact that NCover needs the debug information, so append the debug=&amp;quot;true&amp;quot; attribute to the csc command for the MyApp.dll.&lt;/p&gt;

&lt;p&gt;Next you need to call the ncover.console.exe and pass it any needed parameters like this:-&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &amp;lt;exec program=&lt;span style="color: #006080"&gt;&amp;quot;C:\Program Files\NCover\1.5.8\ncover.console.exe&amp;quot;&lt;/span&gt; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;           commandline=&lt;span style="color: #006080"&gt;&amp;quot;//reg //w &amp;amp;quot;nant_build&amp;amp;quot; &amp;amp;quot;C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe&amp;amp;quot; UnitTests.dll&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;reg = Registers the CoverLib.dll
  &lt;br /&gt;w = Working directory&lt;/p&gt;

&lt;p&gt;You pass ncover the location of the NUnit console application installed on your machine, and then pass that the location of your unit tests library file. Just remember that this script will be run on a build machine, so you must make sure that all paths are correct. On my development machine I run local nant builds using a file like nant_local.build as opposed to nant.build on the cc.net server. This way I don’t ‘accidentally’ run a script that may publish an application to one of our servers when I don’t want to. I have described how to run a NAnt &lt;a href="http://weblogs.asp.net/garrypilkington/archive/2008/02/29/off-on-my-way-to-ci.aspx" target="_blank"&gt;script from your VS IDE here&lt;/a&gt;. When this script is run NCover will generate an XML file called Coverage.xml by default, you can rename it by passing the //xml parameter.&lt;/p&gt;

&lt;p&gt;So now the Coverage.xml file is produced you need to display it using cc.net; to do this edit the ccnet.config file. Mine is located at c:\Program Files\CruiseControl.NET\server. Like &lt;a href="http://weblogs.asp.net/garrypilkington/archive/2008/07/11/cc-net-and-nunit-play-nice-together.aspx" target="_blank"&gt;merging the NUnit results&lt;/a&gt; you have to specify the location of Coverage.xml in the &amp;lt;file&amp;gt; element. Now the cc.net documentation states that you can specify multiple xml files in the same &amp;lt;file&amp;gt; element, but I couldn’t get this to display anything, so what I did was to specify the NUnit and NCover results in separate &amp;lt;file&amp;gt; elements like this:-&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &amp;lt;publishers&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;       &amp;lt;merge&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;         &amp;lt;files&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;           &amp;lt;file&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;             &amp;lt;![CDATA[C:\Projects\MyApp\MyApp\nant_build\test_results\result.xml]]&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;           &amp;lt;/file&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;           &amp;lt;file&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;             &amp;lt;![CDATA[C:\Projects\MyApp\MyApp\Coverage.Xml]]&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;           &amp;lt;/file&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;         &amp;lt;/files&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;       &amp;lt;/merge&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;       &amp;lt;xmllogger /&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     &amp;lt;/publishers&amp;gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Then when a build is run, you get the data integrated in the report like this:-&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/ncover_1_06CAD5CF.png"&gt;&lt;img title="ncover_1" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="63" alt="ncover_1" src="http://weblogs.asp.net/blogs/garrypilkington/ncover_1_thumb_3AFEFF15.png" width="404" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/ncover_2_0AC8D660.png"&gt;&lt;img title="ncover_2" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="244" alt="ncover_2" src="http://weblogs.asp.net/blogs/garrypilkington/ncover_2_thumb_0D055F1C.png" width="115" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Clicking on the NCover Report link on the cc.net main menu gives you a more in depth analysis like showing which line numbers in your .cs files have not been visited by your unit tests. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/garrypilkington/ncover_3_35A3CB23.png"&gt;&lt;img title="ncover_3" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="124" alt="ncover_3" src="http://weblogs.asp.net/blogs/garrypilkington/ncover_3_thumb_59CBB663.png" width="499" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Like I said earlier I was quite shocked, when I first run this a couple of weeks ago I only had 26% coverage. Now I am up to 96% and am trying to cover the edge cases.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6778353" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/4db4bdEpx7M" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/NAnt/default.aspx">NAnt</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Continuous+Integration/default.aspx">Continuous Integration</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/CruiseControl.Net/default.aspx">CruiseControl.Net</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2008/12/11/integrate-ncover-with-cc-net.aspx</feedburner:origLink></item><item><title>Looking at synchronization and one scary tool</title><link>http://feedproxy.google.com/~r/GarrysnetBlog/~3/CfpsL1UwZSI/looking-at-synchronization-and-one-scary-tool.aspx</link><pubDate>Tue, 25 Nov 2008 16:45:58 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6753785</guid><dc:creator>capgpilk</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/garrypilkington/rsscomments.aspx?PostID=6753785</wfw:commentRss><wfw:comment>http://weblogs.asp.net/garrypilkington/commentapi.aspx?PostID=6753785</wfw:comment><comments>http://weblogs.asp.net/garrypilkington/archive/2008/11/25/looking-at-synchronization-and-one-scary-tool.aspx#comments</comments><description>&lt;p&gt;It is funny how things work out, a disaster can lead to opportunities. Last month my main pc at home somehow got a corrupt hard drive and at first I thought I had lost all my private data (family pictures, documents etc), the drive wasn’t backed up as it was a mirrored drive, which I had thought would be an alright disaster recovery mechanism. It happened while I was upgrading to Server 2008. I broke the mirror and disconnected them. So the drives themselves weren’t connected at the time of upgrade, it was when I reconnected them after the upgrade was successful, the OS just couldn’t see them, maybe a corrupt partition table. I even rolled back to Server 2003, but nothing. The most important thing was that I had to recover that data somehow. This lead me to a piece of software called &lt;a href="http://www.file-recovery.net/" target="_blank"&gt;Active File Recovery&lt;/a&gt; which is just so simple to use. To cut a long story short I managed to recover all my missing data. But one thing that really made me think was the fact that this software could see my data &lt;strong&gt;and&lt;/strong&gt; all previous owners data (it was a 2nd hand drive bought from a computer fair).&lt;/p&gt;  &lt;p&gt;I have learnt several things from this experience, these being:-&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;I need to use a more reliable medium. Using new hard drives instead of 2nd hand ones may have prevented this issue, but at the time (2002) I made the purchase there wasn’t a lot of data and it was the only viable option.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;I need a disaster recovery plan. Yes even for your home pc. I chose not to use a backup tool for my data for the simple fact that as there was around 13000 files, it would have took too long to run a back up on a machine which wasn’t permanently powered up.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Be aware of old data. If upgrading an old hard drive, keep in mind that the data may still be recoverable. Dispose with care. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Now I have my data back I needed to find a mechanism which would protect my data with the least amount of administration work. That is I don’t want to have to remember to run a back up every time I add a file to my important documents drive. This is what has lead me to the Synchronization Framework. Using an expanded on version of the &lt;a href="http://msdn.microsoft.com/en-us/sync/bb887623.aspx" target="_blank"&gt;file synchronization example&lt;/a&gt; I now have a mechanism which will synchronize my important docs with my NAS, running in the background as a service. I can sleep better at night now, but what if we have a flood or worse? All my data is still in the same location. My next personal project is to also get it to synchronize with the cloud; hello Live Mesh.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6753785" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/GarrysnetBlog/~4/CfpsL1UwZSI" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/garrypilkington/archive/tags/Sync+Framework/default.aspx">Sync Framework</category><feedburner:origLink>http://weblogs.asp.net/garrypilkington/archive/2008/11/25/looking-at-synchronization-and-one-scary-tool.aspx</feedburner:origLink></item></channel></rss>
