<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>DotNetDevDude - NerdDinnerAdvanced</title>
    <link>http://dotnetdevdude.com/Blog/</link>
    <description>Random thoughts, insights, and questions in the world of a .Net dude</description>
    <language>en-us</language>
    <copyright>Keith Burnell</copyright>
    <lastBuildDate>Sat, 30 May 2009 04:05:00 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>keith@dotnetdevdude.com</managingEditor>
    <webMaster>keith@dotnetdevdude.com</webMaster>
    <item>
      <trackback:ping>http://dotnetdevdude.com/Blog/Trackback.aspx?guid=34fb669a-d1ef-481f-bc1a-efbe1e3ffebf</trackback:ping>
      <pingback:server>http://dotnetdevdude.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://dotnetdevdude.com/Blog/PermaLink,guid,34fb669a-d1ef-481f-bc1a-efbe1e3ffebf.aspx</pingback:target>
      <dc:creator>DotNetDevDude</dc:creator>
      <wfw:comment>http://dotnetdevdude.com/Blog/CommentView,guid,34fb669a-d1ef-481f-bc1a-efbe1e3ffebf.aspx</wfw:comment>
      <wfw:commentRss>http://dotnetdevdude.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=34fb669a-d1ef-481f-bc1a-efbe1e3ffebf</wfw:commentRss>
      <slash:comments>7</slash:comments>
      <title>Nerd Dinner For The Real World – Part 3 (Implementing the Spark View Engine)</title>
      <guid isPermaLink="false">http://dotnetdevdude.com/Blog/PermaLink,guid,34fb669a-d1ef-481f-bc1a-efbe1e3ffebf.aspx</guid>
      <link>http://DotNetDevDude.com/Blog/2009/05/30/NerdDinnerForTheRealWorldPart3ImplementingTheSparkViewEngine.aspx</link>
      <pubDate>Sat, 30 May 2009 04:05:00 GMT</pubDate>
      <description>&lt;p&gt;
I have a few issues with the standard ASP.NET MVC view engine.&amp;#160; First off it
is too verbose…you have type too much and in my opinion the views don’t look like
html.&amp;#160; Luckily there are alternatives.&amp;#160; One of the most popular ASP.NET
MVC view engine replacements is &lt;a href="http://www.sparkviewengine.com/" target="_blank"&gt;Spark&lt;/a&gt;.&amp;#160;
Spark is replacement view engine that allows you to type less and makes your Views
much easier to read.&amp;#160; So for part 3 of NerdDinnerAdvanced I am replacing the
built in ASP.NET MVC view engine with Spark.
&lt;/p&gt;
&lt;p&gt;
Replacing the view engine in the NerdDinnerAdvanced project was very straight forward.&amp;#160;
Here are the steps.
&lt;/p&gt;
&lt;ol&gt;
&lt;ol&gt;
&lt;li&gt;
Reference Spark.dll and Spark.Web.MVC.dll in NerdDinnerAdvanced.UI 
&lt;br /&gt;
&lt;img style="border-right-width: 0px; margin: 0px 0px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Spark" border="0" alt="Spark" src="http://dotnetdevdude.com/Blog/content/binary/WindowsLiveWriter/NerdDinnerForTheReadWorldPart3Implementi_1246E/Spark_1.png" width="220" height="71" /&gt; 
&lt;/li&gt;
&lt;li&gt;
Register Spark as a view engine in Global.asax Application_Start 
&lt;br /&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 0px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 0px" 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: #f4f4f4; 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: #008000"&gt;///
&amp;lt;summary&amp;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: #f4f4f4; 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: #008000"&gt;///
Application Start&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: #008000"&gt;///
&amp;lt;/summary&amp;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: #f4f4f4; 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: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Application_Start()
{&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;    RegisterRoutes(RouteTable.Routes);&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: #f4f4f4; 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: #008000"&gt;//Wire
Up Spark as our ViewEngine (Step 1)&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;    SparkEngineStarter.RegisterViewEngine();&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: #f4f4f4; 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: #008000"&gt;//Initialize
IoC&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;    InversionOfControlHelper.Initialize();&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: #f4f4f4; 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: #008000"&gt;//Wire
up controller factory&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;    ControllerBuilder.Current.SetControllerFactory(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; IoCControllerFactory());&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: #f4f4f4; 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;/li&gt;
&lt;li&gt;
Add a declaration for the Spark configuration section to the Web.config 
&lt;br /&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 0px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 0px" 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: #f4f4f4; 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;!-- Spark Config Section Declaration (Step 2) --&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: #f4f4f4; 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;section name=&lt;span style="color: #006080"&gt;&amp;quot;spark&amp;quot;&lt;/span&gt; type=&lt;span style="color: #006080"&gt;&amp;quot;Spark.Configuration.SparkSectionHandler,
Spark&amp;quot;&lt;/span&gt;/&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
Add Spark configuration to the Web.config 
&lt;br /&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 0px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 0px" 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: #f4f4f4; 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;!-- Spark Configuration Section --&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: #f4f4f4; 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;spark&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;    &amp;lt;compilation debug=&lt;span style="color: #006080"&gt;&amp;quot;true&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: #f4f4f4; 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;assemblies&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;        &amp;lt;add assembly=&lt;span style="color: #006080"&gt;&amp;quot;NerdDinnerAdvanced.UI&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: #f4f4f4; 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;add assembly=&lt;span style="color: #006080"&gt;&amp;quot;System.Web.Mvc,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&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;      &amp;lt;/assemblies&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: #f4f4f4; 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;/compilation&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;    &amp;lt;pages&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: #f4f4f4; 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;namespaces&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;        &amp;lt;add &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt;=&lt;span style="color: #006080"&gt;&amp;quot;System.Collections.Generic&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: #f4f4f4; 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;add &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt;=&lt;span style="color: #006080"&gt;&amp;quot;System.Linq&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;        &amp;lt;add &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt;=&lt;span style="color: #006080"&gt;&amp;quot;System.Web.Mvc&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: #f4f4f4; 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;add &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt;=&lt;span style="color: #006080"&gt;&amp;quot;System.Web.Mvc.Html&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;        &amp;lt;add &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt;=&lt;span style="color: #006080"&gt;&amp;quot;System.Web.Mvc.Ajax&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: #f4f4f4; 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;add &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt;=&lt;span style="color: #006080"&gt;&amp;quot;NerdDinnerAdvanced.Domain.Models&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;      &amp;lt;/namespaces&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: #f4f4f4; 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;/pages&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: #f4f4f4; 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;use content=&lt;span style="color: #006080"&gt;&amp;quot;MainContent&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&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;/spark&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
Create Spark master page 
&lt;p style="padding-top: 0px"&gt;
How master pages are implemented in Spark is very cool.&amp;#160; I am not going to go
into details all the ways you can implement master pages in Spark, but you can check
it out &lt;a href="http://www.sparkviewengine.com/documentation/master-layouts" target="_blank"&gt;here&lt;/a&gt;.&amp;#160;
I am going to use the default behavior in which Spark will look for a file name Application.spark
in either the Views/Layout or Views/Shared folders and will apply that to all the
views in project.&amp;#160; So I no longer have to explicitly tell my view what master
to use. So to setup our master page we need to;
&lt;/p&gt;
&lt;ol type="a"&gt;
&lt;li&gt;
Add a new class file under Views –&amp;gt; Shared and name it Application.spark. 
&lt;/li&gt;
&lt;li&gt;
Copy all the code from Site.master into Application.spark 
&lt;/li&gt;
&lt;li&gt;
Remove the Page directive 
&lt;/li&gt;
&lt;li&gt;
Remove the title content place holder 
&lt;/li&gt;
&lt;li&gt;
Replace the main content place holder with Spark content div 
&lt;br /&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 0px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 0px" 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: #f4f4f4; 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;div id=&lt;span style="color: #006080"&gt;&amp;quot;content&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&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;lt;/div&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
Replace all '&amp;lt;%= xxx %&amp;gt;' with '${ xxx }' 
&lt;/li&gt;
&lt;li&gt;
You should end up with… 
&lt;br /&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 0px 0px 5px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 0px" 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: #f4f4f4; 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;!DOCTYPE html PUBLIC &lt;span style="color: #006080"&gt;&amp;quot;-//W3C//DTD
XHTML 1.0 Transitional//EN&amp;quot;&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&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: #f4f4f4; 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;html xmlns=&lt;span style="color: #006080"&gt;&amp;quot;http://www.w3.org/1999/xhtml&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;&amp;lt;head runat=&lt;span style="color: #006080"&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: #f4f4f4; 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;title&amp;gt;&amp;lt;/title&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;    &amp;lt;link href=&lt;span style="color: #006080"&gt;&amp;quot;../../Content/Site.css&amp;quot;&lt;/span&gt; rel=&lt;span style="color: #006080"&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; type=&lt;span style="color: #006080"&gt;&amp;quot;text/css&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: #f4f4f4; 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;script src=&lt;span style="color: #006080"&gt;&amp;quot;/Scripts/MicrosoftAjax.js&amp;quot;&lt;/span&gt; type=&lt;span style="color: #006080"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;/script&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;    &amp;lt;script src=&lt;span style="color: #006080"&gt;&amp;quot;/Scripts/MicrosoftMvcAjax.js&amp;quot;&lt;/span&gt; type=&lt;span style="color: #006080"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;/script&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: #f4f4f4; 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;script src=&lt;span style="color: #006080"&gt;&amp;quot;/Scripts/jQuery-1.3.2.js&amp;quot;&lt;/span&gt; type=&lt;span style="color: #006080"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;/script&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;&amp;lt;/head&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: #f4f4f4; 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;body&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;    &amp;lt;div &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;=&lt;span style="color: #006080"&gt;&amp;quot;page&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: #f4f4f4; 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: 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;div id=&lt;span style="color: #006080"&gt;&amp;quot;header&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: #f4f4f4; 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;div id=&lt;span style="color: #006080"&gt;&amp;quot;title&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;                &amp;lt;h1&amp;gt;Nerd Dinner For The Real World&amp;lt;/h1&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: #f4f4f4; 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;/div&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;/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: #f4f4f4; 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;div id=&lt;span style="color: #006080"&gt;&amp;quot;logindisplay&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;                &amp;lt;% Html.RenderPartial(&lt;span style="color: #006080"&gt;&amp;quot;LogOnUserControl&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: #f4f4f4; 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;/div&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;            &amp;lt;div id=&lt;span style="color: #006080"&gt;&amp;quot;menucontainer&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: #f4f4f4; 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;ul id=&lt;span style="color: #006080"&gt;&amp;quot;menu&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;                    &amp;lt;li&amp;gt;${ Html.ActionLink(&lt;span style="color: #006080"&gt;&amp;quot;Find
Dinner&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Dinners&amp;quot;&lt;/span&gt;)}&amp;lt;/li&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: #f4f4f4; 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;li&amp;gt;${ Html.ActionLink(&lt;span style="color: #006080"&gt;&amp;quot;Host
Dinner&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Create&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Dinners&amp;quot;&lt;/span&gt;)}&amp;lt;/li&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;                    &amp;lt;li&amp;gt;${ Html.ActionLink(&lt;span style="color: #006080"&gt;&amp;quot;About&amp;quot;&lt;/span&gt;,&lt;span style="color: #006080"&gt;&amp;quot;About&amp;quot;&lt;/span&gt;,&lt;span style="color: #006080"&gt;&amp;quot;Home&amp;quot;&lt;/span&gt;)
}&amp;lt;/li&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: #f4f4f4; 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;/ul&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;            &amp;lt;/div&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: #f4f4f4; 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;/div&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;&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: #f4f4f4; 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;div id=&lt;span style="color: #006080"&gt;&amp;quot;main&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;            &amp;lt;div id=&lt;span style="color: #006080"&gt;&amp;quot;content&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: #f4f4f4; 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;use content=&lt;span style="color: #006080"&gt;&amp;quot;MainContent&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;            &amp;lt;/div&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: #f4f4f4; 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;div id=&lt;span style="color: #006080"&gt;&amp;quot;footer&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;            &amp;lt;/div&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: #f4f4f4; 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;/div&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;    &amp;lt;/div&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: #f4f4f4; 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;/body&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;&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
Convert our first page.&amp;#160; Home/Index.aspx 
&lt;ol&gt;
&lt;li&gt;
Rename Index.aspx to Index.spark 
&lt;/li&gt;
&lt;li&gt;
Remove Page directive 
&lt;/li&gt;
&lt;li&gt;
Remove Title content 
&lt;/li&gt;
&lt;li&gt;
Replace ASP main content tag with Spark main content tag 
&lt;/li&gt;
&lt;li&gt;
Replace all '&amp;lt;%= xxx %&amp;gt;' with '${ xxx }' 
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
Now we ran it!&amp;#160; What to notice here is first of all it runs.&amp;#160; The second
thing to notice is the really cool part.&amp;#160; We are seeing a view created using
the Spark View Engine but we are displaying a partial view created using the standard
ASP.NET MVC View Engine.&amp;#160; The Log In/Out user control is still being rendered
by the default view engine. 
&lt;/li&gt;
&lt;li&gt;
Now we are ready to convert the remaining pages.&amp;#160; One difference from the built
in view engine is how you tell the view about the model.&amp;#160; You need to explicitly
specify what model the view uses. 
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 0px 0px 5px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" 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: #f4f4f4; 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;viewdata model=&lt;span style="color: #006080"&gt;&amp;quot;NerdDinnerAdvanced.UI.Utility.PaginatedCollection&amp;lt;NerdDinnerAdvanced.Domain.Models.Dinner&amp;gt;&amp;quot;&lt;/span&gt;/&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&gt;
&lt;p&gt;
&lt;br /&gt;
The complete code can be downloaded &lt;a href="http://www.dotnetdevdude.com/Downloads/Code/NerdDinnerAdvanced(Part3).zip" target="_blank"&gt;here&lt;/a&gt;.&amp;#160;
Stay tuned for part 4. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://dotnetdevdude.com/Blog/aggbug.ashx?id=34fb669a-d1ef-481f-bc1a-efbe1e3ffebf" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This weblog is sponsored by &lt;a href="http://www.newtelligence.com"&gt;newtelligence AG&lt;/a&gt;. &lt;a href="http://www.jetbrains.com/ruby/features?utm_source=RubyMineUser&amp;utm_medium=Banner&amp;utm_campaign=RubyMine" style="position: relative;display:block; width:120px; height:30px; border:0; margin:0;padding:0;text-decoration:none;text-indent:0;"&gt;&lt;span style="margin: 0;padding: 0;position: absolute;top: -2px;left: 33px;font-size: 9px;cursor:pointer;  background-image:none;border:0;color: #efcedc; font-family: trebuchet ms,arial,sans-serif;font-weight: normal;text-align:left;"&gt;Happy
fan of&lt;/span&gt;&lt;img src="http://www.jetbrains.com/ruby/features/ruby_banners/ruby1/ruby120x30_rubin.gif" alt="Happy fan of" border="0" /&gt;&lt;/a&gt;</description>
      <comments>http://dotnetdevdude.com/Blog/CommentView,guid,34fb669a-d1ef-481f-bc1a-efbe1e3ffebf.aspx</comments>
      <category>Code</category>
      <category>MVC</category>
      <category>NerdDinner</category>
      <category>NerdDinnerAdvanced</category>
      <category>Spark</category>
    </item>
    <item>
      <trackback:ping>http://dotnetdevdude.com/Blog/Trackback.aspx?guid=93d7e473-d95a-4ded-a8ac-f0b037089897</trackback:ping>
      <pingback:server>http://dotnetdevdude.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://dotnetdevdude.com/Blog/PermaLink,guid,93d7e473-d95a-4ded-a8ac-f0b037089897.aspx</pingback:target>
      <dc:creator>DotNetDevDude</dc:creator>
      <wfw:comment>http://dotnetdevdude.com/Blog/CommentView,guid,93d7e473-d95a-4ded-a8ac-f0b037089897.aspx</wfw:comment>
      <wfw:commentRss>http://dotnetdevdude.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=93d7e473-d95a-4ded-a8ac-f0b037089897</wfw:commentRss>
      <slash:comments>12</slash:comments>
      <title>Nerd Dinner For The Real World – Part 2 (NHibernate DAL)</title>
      <guid isPermaLink="false">http://dotnetdevdude.com/Blog/PermaLink,guid,93d7e473-d95a-4ded-a8ac-f0b037089897.aspx</guid>
      <link>http://DotNetDevDude.com/Blog/2009/05/27/NerdDinnerForTheRealWorldPart2NHibernateDAL.aspx</link>
      <pubDate>Wed, 27 May 2009 13:52:17 GMT</pubDate>
      <description>&lt;p&gt;
In part 2 of the NerdDinnerAdvanced code I replaced the LinqToSql DAL with a DAL that
uses &lt;a href="https://www.hibernate.org" target="_blank"&gt;NHibernate&lt;/a&gt;.&amp;nbsp; NHibernate
is an open sourced object relational mapper.&amp;nbsp; If you are not familiar with ORM
and/or NHibernate I highly suggest you check them out.&amp;nbsp; Because of the way we
architected our project in Part 1 implementing an NHibernate DAL had little to no
impact on any code above the DAL.
&lt;/p&gt;
&lt;p&gt;
To start I re-structured the project a little.&amp;nbsp; I created a NerdDinnerAdvanced.Data.LinqToSql
project and moved the LinqToSql DinnerRepository and the NerdDinner.dbml file into
the new project.&amp;nbsp; This left just the IDinnerRepository in the NerdDinnerAdvanced.Data
project.&amp;nbsp; You could certainly move the IDinnerRepository class to the NerdDinnerAdvanced.Common
project and remove the NerdDinnerAdvanced.Data project if you wish.
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="DataAndLinqToSql" alt="DataAndLinqToSql" src="http://dotnetdevdude.com/Blog/content/binary/WindowsLiveWriter/NerdDinnerForTheRealWorldPart2NHibernate_7091/DataAndLinqToSql_1.png" border="0" height="150" width="243"&gt;
&lt;/p&gt;
&lt;p&gt;
Now it was time to create my NHibernate mappings.&amp;nbsp; If you are not familiar with
how ORM’s work the basic concept is that the ORM framework maps data from a database
to your entity/domain objects In order to accomplish this you need to tell the ORM
what tables/columns map to what objects/fields and this is typically done via an XML
file.&amp;nbsp; In this case we only have 2 objects to map, Dinner and Rsvp, so the mapping
would not be complex.&amp;nbsp; Often, though, you are dealing with hundreds of objects
with a lot of fields and the management of the XML mapping files can get very difficult.&amp;nbsp;
For this reason, and because I wanted to have a chance to play with it, I decided
to use &lt;a href="http://fluentnhibernate.org/" target="_blank"&gt;Fluent NHibernate&lt;/a&gt; to
do my mapping.&amp;nbsp; Fluent NHibernate allows you to do your mappings using strongly
typed C# code.
&lt;/p&gt;
&lt;p&gt;
In my NerdDinnerAdvanced.Domain project I created a new folder called Mappings and
added two mapping classes, one for each of my two domain objects.
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border: 0px none ; display: block; float: none; margin-left: auto; margin-right: auto;" title="Mappings" alt="Mappings" src="http://dotnetdevdude.com/Blog/content/binary/WindowsLiveWriter/NerdDinnerForTheRealWorldPart2NHibernate_7091/Mappings_1.png" border="0" height="117" width="208"&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Because this is not a Fluent NHibernate tutorial I am not going to go into detail
on how you create the mappings…and for the most part it is fairly intuitive.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; ///
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
Fluent NHibernate mapping for the Dinner class&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; DinnerMap
: ClassMap&amp;lt;Dinner&amp;gt; { &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; DinnerMap()
{ WithTable(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Dinners"&lt;/span&gt;);
SetAttribute(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"lazy"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"false"&lt;/span&gt;);
Id(x =&amp;gt; x.DinnerId); Map(x =&amp;gt; x.Title); Map(x =&amp;gt; x.Description); Map(x =&amp;gt;
x.EventDate); Map(x =&amp;gt; x.HostedBy); Map(x =&amp;gt; x.Address); Map(x =&amp;gt; x.Country);
Map(x =&amp;gt; x.ContactPhone); Map(x =&amp;gt; x.Latitude); Map(x =&amp;gt; x.Longitude); HasMany(x
=&amp;gt; x.Rsvps).Inverse().KeyColumnNames.Add(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"DinnerId"&lt;/span&gt;).Cascade.All().SetAttribute(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"lazy"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"false"&lt;/span&gt;);
} }&lt;/span&gt;&lt;/pre&gt;&lt;/blockquote&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Next it was time to create the NHibernate DAL so I added a NerdDinnerAdvanced.Data.NHibernate
project to the solution.&amp;nbsp; The first thing you have to do when using NHibernate,
after creating your mapping files, is create your NHibernate Session class.&amp;nbsp;
Session to NHibernate is like DataContext to Linq.&amp;nbsp;&amp;nbsp; The Session for the
most part contains connection string and mapping info and it is the mediator between
you and your data.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; ///
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
NHibernate session factory&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; SessionFactory
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; ISessionFactory
CreateSessionFactory() { &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(c =&amp;gt; c.Is(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Data
Source=keith-166938fd4;Initial Catalog=NerdDinner;Integrated Security=True"&lt;/span&gt;)))
.Mappings(m =&amp;gt; m.FluentMappings.AddFromAssemblyOf&amp;lt;Dinner&amp;gt;()) .BuildSessionFactory();
} }&lt;/span&gt;&lt;/pre&gt;&lt;/blockquote&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
After creating the NHibernate Session class I can now implement my DinnerRepository
using NHibernate.&amp;nbsp; Below is an example of the FindAllDinners method.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
Returns a list of all dinners&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;returns&amp;gt;List of all dinners&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; IQueryable&amp;lt;Dinner&amp;gt;
FindAllDinners() {&lt;br&gt;
var sessionFactory &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; SessionFactory.CreateSessionFactory();&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;using&lt;/span&gt; (var
session &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; sessionFactory.OpenSession())
{&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;using&lt;/span&gt; (session.BeginTransaction())
{&lt;br&gt;
&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; session.CreateCriteria(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(Dinner)).List&amp;lt;Dinner&amp;gt;().AsQueryable();&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
}&lt;/span&gt;
&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
After completing the DinnerRepository we can tell our application to use the the new
DAL by changing one line in our InversionOfControlHelper class.
&lt;/p&gt;
&lt;p&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; ///
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
Initializes the inversion of control mappings&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; Initialize()
{&lt;br&gt;
StructureMapConfiguration.ResetAll();&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;//Tell
Structure Map we are using Fluent mapping rather than onfiguration file based mapping!&lt;/span&gt; StructureMapConfiguration.UseDefaultStructureMapConfigFile &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;false&lt;/span&gt;;&lt;br&gt;
&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;//This
is the only line of code outside of the DAL that needed to be modified to implement
the NHibernate data access layer!&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;//StructureMapConfiguration.BuildInstancesOf&amp;lt;IDinnerRepository&amp;gt;().TheDefaultIsConcreteType&amp;lt;Data.LinqToSql.DinnerRepository&amp;gt;();&lt;/span&gt;
&lt;br&gt;
&lt;b&gt; &lt;u&gt;StructureMapConfiguration.BuildInstancesOf&amp;lt;IDinnerRepository&amp;gt;().TheDefaultIsConcreteType&amp;lt;Data.NHibernate.DinnerRepository&amp;gt;();&lt;/u&gt;
&lt;br&gt;
&lt;/b&gt; StructureMapConfiguration.BuildInstancesOf&amp;lt;IDinnerServices&amp;gt;().TheDefaultIsConcreteType&amp;lt;DinnerServices&amp;gt;();&lt;br&gt;
}&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&gt;
&lt;p&gt;
Once again the complete source can be downloaded &lt;a href="http://www.DotNetDevDude.com/Downloads/Code/NerdDinnerAdvanced%28Part2%29.zip"&gt;here&lt;/a&gt;.&amp;nbsp;
Stay tuned for Part 3!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://dotnetdevdude.com/Blog/aggbug.ashx?id=93d7e473-d95a-4ded-a8ac-f0b037089897" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This weblog is sponsored by &lt;a href="http://www.newtelligence.com"&gt;newtelligence AG&lt;/a&gt;. &lt;a href="http://www.jetbrains.com/ruby/features?utm_source=RubyMineUser&amp;utm_medium=Banner&amp;utm_campaign=RubyMine" style="position: relative;display:block; width:120px; height:30px; border:0; margin:0;padding:0;text-decoration:none;text-indent:0;"&gt;&lt;span style="margin: 0;padding: 0;position: absolute;top: -2px;left: 33px;font-size: 9px;cursor:pointer;  background-image:none;border:0;color: #efcedc; font-family: trebuchet ms,arial,sans-serif;font-weight: normal;text-align:left;"&gt;Happy
fan of&lt;/span&gt;&lt;img src="http://www.jetbrains.com/ruby/features/ruby_banners/ruby1/ruby120x30_rubin.gif" alt="Happy fan of" border="0" /&gt;&lt;/a&gt;</description>
      <comments>http://dotnetdevdude.com/Blog/CommentView,guid,93d7e473-d95a-4ded-a8ac-f0b037089897.aspx</comments>
      <category>Code</category>
      <category>MVC</category>
      <category>NerdDinner</category>
      <category>NerdDinnerAdvanced</category>
      <category>NHibernate</category>
    </item>
    <item>
      <trackback:ping>http://dotnetdevdude.com/Blog/Trackback.aspx?guid=c2f77920-8379-446d-9447-7f425e37d352</trackback:ping>
      <pingback:server>http://dotnetdevdude.com/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://dotnetdevdude.com/Blog/PermaLink,guid,c2f77920-8379-446d-9447-7f425e37d352.aspx</pingback:target>
      <dc:creator>DotNetDevDude</dc:creator>
      <wfw:comment>http://dotnetdevdude.com/Blog/CommentView,guid,c2f77920-8379-446d-9447-7f425e37d352.aspx</wfw:comment>
      <wfw:commentRss>http://dotnetdevdude.com/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c2f77920-8379-446d-9447-7f425e37d352</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <title>NerdDinner For The Real World – Part 1</title>
      <guid isPermaLink="false">http://dotnetdevdude.com/Blog/PermaLink,guid,c2f77920-8379-446d-9447-7f425e37d352.aspx</guid>
      <link>http://DotNetDevDude.com/Blog/2009/05/16/NerdDinnerForTheRealWorldPart1.aspx</link>
      <pubDate>Sat, 16 May 2009 21:10:32 GMT</pubDate>
      <description>&lt;p&gt;
The first chapter of &lt;a href="http://www.wrox.com/WileyCDA/WroxTitle/Professional-ASP-NET-MVC-1-0.productCd-0470384611.html"&gt;Professional
ASP.NET MVC 1.0&lt;/a&gt; walks you through creating the basic &lt;a href="http://www.nerddinner.com/"&gt;NerdDinner&lt;/a&gt; site.&amp;nbsp;
This is a great introduction to ASP.NET MVC but really isn’t something you could as
reference for creating a real world ASP.MVC site.&amp;nbsp; With this in mind I set out
on a multi part project to create a real world ASP.NET reference application based
on the base NerdDinner code.
&lt;/p&gt;
&lt;p&gt;
It the first installation of what I am calling NerdDinnerAdvanced I extended the base
NerdDinner code in the following ways;
&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
Created 3-tier architecture.&amp;nbsp; One of the major misconceptions about ASP.NET MVC
is that it is a UI framework.&amp;nbsp; I think this is mainly due to the fact that the
major changes that developers need to wrap their head around are in the UI.&amp;nbsp;
To help alleviate this misconception I structured the MVC project architecturally
that developers who have experience in n-tier architecture will find familiar. 
&lt;br&gt;
&amp;nbsp;The layers, as you can see highlighted above, are UI, Business, and Data.&amp;nbsp;
Because of the overall simplistic nature of the underlying code I did not include
a Service layer.&amp;nbsp; The other projects are shared by the layers.&amp;nbsp; The Domain
project contains my models and the Common project contains common utility classes. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p align="center"&gt;
&amp;nbsp;&lt;img src="http://www.DotNetDevDude.com/Images/FileStructure.png"&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
The base NerdDinner code used LINQ to SQL and was content with passing the LINQ to
SQL entities between the layers of the application.&amp;nbsp; I would guess that Mr. Gu
did this for simplicity and brevity and not a show of best practice.&amp;nbsp; If you
are asking yourself what is wrong with architecting around LINQ to SQL entities I
would recommend picking up Dino Esposito’s latest &lt;a href="http://www.microsoft.com/learning/en/us/Books/12863.aspx"&gt;book&lt;/a&gt;.&amp;nbsp;
The main reason is that you are tightly coupling yourself to the database.&amp;nbsp; So
in my Domain project I created a Models namespace and created Dinner, Rsvp, and DinnerFormView
domain objects. 
&lt;br&gt;
&lt;div align="center"&gt;&lt;a href=""&gt;&lt;img src="http://www.DotNetDevDude.com/Images/DomainObjects.png"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
&amp;nbsp; Implemented &lt;a href="http://martinfowler.com/articles/injection.html"&gt;Inversion
Of Control/Dependency Injection&lt;/a&gt; using &lt;a href="http://structuremap.sourceforge.net/Default.htm"&gt;Structure
Map&lt;/a&gt;.&amp;nbsp; The base NerdDinner code used manual IoC/Di in the DinnersController
but I decided to take that a step further because I am on a bit of an Ioc/Di fix lately.&amp;nbsp;
I implemented it on the repository and the dinner services business object as well
as the Dinner and Rsvp controllers. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
Implemented a full suite of unit testing using &lt;a href="http://code.google.com/p/moq/"&gt;MOQ&lt;/a&gt; for
mocking objects. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;The code can be downloaded &lt;a href="http://www.DotNetDevDude.com/Downloads/Code/NerdDinnerAdvanced%28Part1%29.zip"&gt;here&lt;/a&gt;.&amp;nbsp;
Stay tuned for the next installment which will include nHibernate as the DAL.&lt;br&gt;
&lt;/blockquote&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://dotnetdevdude.com/Blog/aggbug.ashx?id=c2f77920-8379-446d-9447-7f425e37d352" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This weblog is sponsored by &lt;a href="http://www.newtelligence.com"&gt;newtelligence AG&lt;/a&gt;. &lt;a href="http://www.jetbrains.com/ruby/features?utm_source=RubyMineUser&amp;utm_medium=Banner&amp;utm_campaign=RubyMine" style="position: relative;display:block; width:120px; height:30px; border:0; margin:0;padding:0;text-decoration:none;text-indent:0;"&gt;&lt;span style="margin: 0;padding: 0;position: absolute;top: -2px;left: 33px;font-size: 9px;cursor:pointer;  background-image:none;border:0;color: #efcedc; font-family: trebuchet ms,arial,sans-serif;font-weight: normal;text-align:left;"&gt;Happy
fan of&lt;/span&gt;&lt;img src="http://www.jetbrains.com/ruby/features/ruby_banners/ruby1/ruby120x30_rubin.gif" alt="Happy fan of" border="0" /&gt;&lt;/a&gt;</description>
      <comments>http://dotnetdevdude.com/Blog/CommentView,guid,c2f77920-8379-446d-9447-7f425e37d352.aspx</comments>
      <category>Code</category>
      <category>MVC</category>
      <category>NerdDinner</category>
      <category>NerdDinnerAdvanced</category>
    </item>
  </channel>
</rss>