<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Peak bytes</title>
	<atom:link href="http://peakbyte.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://peakbyte.wordpress.com</link>
	<description>System.Object.ToString() == "String Theory"</description>
	<lastBuildDate>Tue, 19 Jul 2011 09:59:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='peakbyte.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Peak bytes</title>
		<link>http://peakbyte.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://peakbyte.wordpress.com/osd.xml" title="Peak bytes" />
	<atom:link rel='hub' href='http://peakbyte.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Cross-Domain, Ajax Fundamental understanding</title>
		<link>http://peakbyte.wordpress.com/2010/06/04/cross-domain-ajax-fundamental-understanding/</link>
		<comments>http://peakbyte.wordpress.com/2010/06/04/cross-domain-ajax-fundamental-understanding/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 11:02:00 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Problem]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[FX.Web.ASPNET]]></category>

		<guid isPermaLink="false">https://peakbyte.wordpress.com/2010/06/04/cross-domain-ajax-fundamental-understanding/</guid>
		<description><![CDATA[I had promised my students that we would implement a “Find nearest XXXX” feature in our on going project. I was doing this for the first time and thought it would not be difficult. But, most of my time while preparing for the class, I was frustrated. I could not come up with a WCF [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=190&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had promised my students that we would implement a “Find nearest XXXX” feature in our on going project. I was doing this for the first time and thought it would not be difficult. But, most of my time while preparing for the class, I was frustrated. </p>
<p>I could not come up with a WCF Web Service (hosted on Visual Studio’s development web server eg., http://localhost:1234/MyService.svc ) that could be invoked by Javascript on my website (hosted again on Visual Studio’s development web server eg., http://localhost:9876/MyWebsite/Default.aspx ).</p>
<p>Due to time constraints, I abandoned the WCF Service implementation and went in for the <a href="http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/" target="_blank">ASP.NET Ajax Page Methods</a></p>
<p>It’s only after reading this nice article, I understand the mistake I made or the way the cross-domain web requests work.</p>
<p><a href="http://dotnetslackers.com/columns/ajax/MashitUpwithASPNETAJAX.aspx" target="_blank">Mash-it Up with ASP.NET AJAX: Using a proxy to access remote API</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/190/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=190&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2010/06/04/cross-domain-ajax-fundamental-understanding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET MVC1.0 installer and VS2008 AddOns</title>
		<link>http://peakbyte.wordpress.com/2010/05/25/asp-net-mvc1-0-installer-and-vs2008-addons/</link>
		<comments>http://peakbyte.wordpress.com/2010/05/25/asp-net-mvc1-0-installer-and-vs2008-addons/#comments</comments>
		<pubDate>Tue, 25 May 2010 13:15:11 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://peakbyte.wordpress.com/2010/05/25/asp-net-mvc1-0-installer-and-vs2008-addons/</guid>
		<description><![CDATA[Today I tried all things in vain to try and install ASP.NET MVC 1.0 on to my machine and it just kept failing. Possible causes, upon Binging focused on conflicting Visual Studio 2008 addons. Among the list of such addons, I had PowerCommands. But, despite uninstalling it, mvc installer complained. Then I begun uninstalling other [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=189&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I tried all things in vain to try and install ASP.NET MVC 1.0 on to my machine and it just kept failing. </p>
<p>Possible causes, upon Binging focused on conflicting Visual Studio 2008 addons. Among the list of such addons, I had PowerCommands. But, despite uninstalling it, mvc installer complained.</p>
<p>Then I begun uninstalling other possible addons (not listed in the mvc installer readme file). The first to go was SlickEdit gadgets.</p>
<p>Lo and behold, the MVC installation was successful.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/189/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=189&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2010/05/25/asp-net-mvc1-0-installer-and-vs2008-addons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>
	</item>
		<item>
		<title>Another Foray into Functional Programming</title>
		<link>http://peakbyte.wordpress.com/2009/11/17/another-foray-into-functional-programming/</link>
		<comments>http://peakbyte.wordpress.com/2009/11/17/another-foray-into-functional-programming/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 01:20:00 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[BackToBasics]]></category>
		<category><![CDATA[Lang.*]]></category>
		<category><![CDATA[Lang.Erlang]]></category>
		<category><![CDATA[Lang.F#]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/2009/11/17/another-foray-into-functional-programming/</guid>
		<description><![CDATA[VS2010 beta2 has come with F#. Not that I was not interested in Functional Programming before. I’ve had a go at Erlang nearly 6 months ago and must say that I loved it. But the prospect of Functional Programming with .NET CLR (or rather DLR) definitely gives F# a special place. More over, the most [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=188&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>VS2010 beta2 has come with F#. Not that I was not interested in Functional Programming before. I’ve had a go at Erlang nearly 6 months ago and must say that I loved it. But the prospect of Functional Programming with .NET CLR (or rather DLR) definitely gives F# a special place. </p>
<p>More over, the most familiar IDE of Visual Studio is simply wonderful. I must admit, I’ve not yet started doing my katas on F#, partly because the functional programming concepts need to be ingrained before moving ploughing ahead. So, watched a couple of interesting videos tonight.</p>
<p>First, on Channel9 tagged “Lecture Series”, “Functional Programming” that can be found here:</p>
<p><a href="http://channel9.msdn.com/shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1/" target="_blank">http://channel9.msdn.com/shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1/</a></p>
<p>The second was with my favourite teacher Venkat Subramaniam in it, with my favourite host Carl Franklin, on my favourite DotNet TV show -&gt; DNRtv. It can be found here:</p>
<p><a title="http://is.gd/4WGP2" href="http://is.gd/4WGP2" target="_blank">http://is.gd/4WGP2</a></p>
<p>Got to say I enjoyed it despite the brilliant London weather!</p>
<p>Some more resources:</p>
<ul>
<li>F# CTP for VS2008</li>
<blockquote><p><a href="http://fsharp.net" target="_blank">http://fsharp.net</a></p>
</blockquote>
<li>Erlang tagged videos on Best Tech Videos</li>
<blockquote><p><a href="http://www.bestechvideos.com/tag/erlang" target="_blank">http://www.bestechvideos.com/tag/erlang</a></p>
</blockquote>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=188&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2009/11/17/another-foray-into-functional-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>
	</item>
		<item>
		<title>How to use Ninject IoC with ASP.NET MVC</title>
		<link>http://peakbyte.wordpress.com/2009/09/28/how-to-use-ninject-ioc-with-asp-net-mvc/</link>
		<comments>http://peakbyte.wordpress.com/2009/09/28/how-to-use-ninject-ioc-with-asp-net-mvc/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 23:41:11 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/?p=185</guid>
		<description><![CDATA[The following are the detailed steps to use Ninject IoC with ASP.NET MVC &#160; Download and install TortoiseSVN TortoiseSVN is a Subversion client that allows you to manage source control tasks from within Windows Explorer. Download the source code for Ninject from google code The Ninject source code is hosted in Google Code website. To [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=185&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>The following are the detailed steps to use Ninject IoC with ASP.NET MVC</h3>
<p>&#160;</p>
<h5>Download and install TortoiseSVN </h5>
<p><a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a> is a Subversion client that allows you to manage source control tasks from within Windows Explorer. </p>
<h5>Download the source code for <a href="http://ninject.org/" target="_blank">Ninject</a> from google code</h5>
<p>The Ninject source code is hosted in Google Code website. To download the code to PC, we will use TortoiseSVN. Before that we need the URL of the repository. This is available in the following url:</p>
<p><a href="http://code.google.com/p/ninject/source/checkout">http://code.google.com/p/ninject/source/checkout</a></p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja1.png"><img style="display:inline;border-width:0;" title="Ninja1" border="0" alt="Ninja1" src="http://peakbyte.files.wordpress.com/2009/09/ninja1_thumb.png?w=554&#038;h=330" width="554" height="330" /></a> </p>
<p>Then using Windows Explorer use the “Export” option of TortoiseSVN to get a copy of the source code as shown in the figures below:</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja2.png"><img style="display:inline;border-width:0;" title="Ninja2" border="0" alt="Ninja2" src="http://peakbyte.files.wordpress.com/2009/09/ninja2_thumb.png?w=554&#038;h=464" width="554" height="464" /></a> </p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja3.png"><img style="display:inline;border-width:0;" title="Ninja3" border="0" alt="Ninja3" src="http://peakbyte.files.wordpress.com/2009/09/ninja3_thumb.png?w=549&#038;h=447" width="549" height="447" /></a> </p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja4.png"><img style="display:inline;border-width:0;" title="Ninja4" border="0" alt="Ninja4" src="http://peakbyte.files.wordpress.com/2009/09/ninja4_thumb.png?w=554&#038;h=269" width="554" height="269" /></a> </p>
<h5>Build the Ninject source code </h5>
<p>Once we have the source code, we need to build it to generate the two assemblies we need.</p>
<p>We will run the Build.cmd file that will trigger a Nant build script which will eventually build the entire source.</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja5.png"><img style="display:inline;border-width:0;" title="Ninja5" border="0" alt="Ninja5" src="http://peakbyte.files.wordpress.com/2009/09/ninja5_thumb.png?w=554&#038;h=259" width="554" height="259" /></a> </p>
<p>Once we have built the source code successfully, we can find the two assemblies we need in the /bin/debug folder as shown below:</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja6.png"><img style="display:inline;border-width:0;" title="Ninja6" border="0" alt="Ninja6" src="http://peakbyte.files.wordpress.com/2009/09/ninja6_thumb.png?w=554&#038;h=483" width="554" height="483" /></a> </p>
<h5>Create a new MVC project</h5>
<p>&#160;</p>
<p>Now, let us create a new MVC project using Visual Studio 2008.</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/mvc1.png"><img style="display:inline;border-width:0;" title="MVC1" border="0" alt="MVC1" src="http://peakbyte.files.wordpress.com/2009/09/mvc1_thumb.png?w=554&#038;h=455" width="554" height="455" /></a> </p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/mvc2.png"><img style="display:inline;border-width:0;" title="MVC2" border="0" alt="MVC2" src="http://peakbyte.files.wordpress.com/2009/09/mvc2_thumb.png?w=554&#038;h=428" width="554" height="428" /></a> </p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/mvc3.png"><img style="display:inline;border-width:0;" title="MVC3" border="0" alt="MVC3" src="http://peakbyte.files.wordpress.com/2009/09/mvc3_thumb.png?w=335&#038;h=582" width="335" height="582" /></a> </p>
<p>Let us test if all is fine by running the application</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/mvc4.png"><img style="display:inline;border-width:0;" title="MVC4" border="0" alt="MVC4" src="http://peakbyte.files.wordpress.com/2009/09/mvc4_thumb.png?w=554&#038;h=398" width="554" height="398" /></a> </p>
</p>
<h5>Making the MVC project a meaningful project</h5>
<p>Before jumping into adding references to the Ninject assemblies, let us modify this MVC project to do something useful.</p>
<p>We are going to create an application that will help us browse through the bills in a Parliament. The Parliament has two chambers. House of Lords and House of Commons and each have their own bills at anytime which they are legislating about.</p>
<p>I am going to show only the code relevant to this topic, so will not show in detail all the steps in creating this. The source code for this can be downloaded to view the complete implementation minus Ninject integration. Some screen shots of the application is shown below:</p>
<h6>Home Page</h6>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/parl1.png"><img style="display:inline;border-width:0;" title="Parl1" border="0" alt="Parl1" src="http://peakbyte.files.wordpress.com/2009/09/parl1_thumb.png?w=554&#038;h=398" width="554" height="398" /></a> </p>
<h6>Bills page</h6>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/parl2.png"><img style="display:inline;border-width:0;" title="Parl2" border="0" alt="Parl2" src="http://peakbyte.files.wordpress.com/2009/09/parl2_thumb.png?w=554&#038;h=398" width="554" height="398" /></a> </p>
<h6>Bills in House of Lords</h6>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/parl3.png"><img style="display:inline;border-width:0;" title="Parl3" border="0" alt="Parl3" src="http://peakbyte.files.wordpress.com/2009/09/parl3_thumb.png?w=554&#038;h=398" width="554" height="398" /></a> </p>
<h6>Bills in House of Commons</h6>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/parl4.png"><img style="display:inline;border-width:0;" title="Parl4" border="0" alt="Parl4" src="http://peakbyte.files.wordpress.com/2009/09/parl4_thumb.png?w=554&#038;h=398" width="554" height="398" /></a> </p>
<p>The following shown the Solution Explorer highlighting the Code Files needed to accomplish the above application.</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/mvc5.png"><img style="display:inline;border-width:0;" title="MVC5" border="0" alt="MVC5" src="http://peakbyte.files.wordpress.com/2009/09/mvc5_thumb.png?w=335&#038;h=728" width="335" height="728" /></a> </p>
<h5>The case for Dependency Injection</h5>
<p>The List of Bills displayed in the website is at the moment “fake” data coming from a class called “FakeDepository”. </p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:752d7344-6128-42ea-a188-4baeb3331f57" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#8080c0;">namespace</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">JoeBloggsStore</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">DataModel</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">Concrete</span></li>
<li><span style="background:#181818;color:#e0e0e0;">{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">class</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">FakeDataRepository</span><span style="background:#181818;color:#e0e0e0;"> : </span><span style="background:#181818;color:#c7c7f1;">IDataRepository</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// fake list of bills in house of lords</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">private</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">static</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">IQueryable</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#8080c0;">string</span><span style="background:#181818;color:#e0e0e0;">&gt; </span><span style="background:#181818;color:#fef1a9;">lordsBills</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">List</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#8080c0;">string</span><span style="background:#181818;color:#e0e0e0;">&gt;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;Live Music Bill [HL]&#8220;</span><span style="background:#181818;color:#e0e0e0;">,</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;Constitutional Reform Bill [HL]&#8220;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}.</span><span style="background:#181818;color:#fef1a9;">AsQueryable</span><span style="background:#181818;color:#e0e0e0;">();</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// fake list of bills in house of commons</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">private</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">static</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">IQueryable</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#8080c0;">string</span><span style="background:#181818;color:#e0e0e0;">&gt; </span><span style="background:#181818;color:#fef1a9;">commonsBills</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">List</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#8080c0;">string</span><span style="background:#181818;color:#e0e0e0;">&gt;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;Maximum Wage Bill&#8221;</span><span style="background:#181818;color:#e0e0e0;">,</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;Bankers&#8217; Pensions (Limits) Bill&#8221;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}.</span><span style="background:#181818;color:#fef1a9;">AsQueryable</span><span style="background:#181818;color:#e0e0e0;">();</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">IQueryable</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#8080c0;">string</span><span style="background:#181818;color:#e0e0e0;">&gt; </span><span style="background:#181818;color:#fef1a9;">LordsBills</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">get</span><span style="background:#181818;color:#e0e0e0;"> { </span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">lordsBills</span><span style="background:#181818;color:#e0e0e0;">; }</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">IQueryable</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#8080c0;">string</span><span style="background:#181818;color:#e0e0e0;">&gt; </span><span style="background:#181818;color:#fef1a9;">CommonsBills</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">get</span><span style="background:#181818;color:#e0e0e0;"> { </span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">commonsBills</span><span style="background:#181818;color:#e0e0e0;">; }</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">}</span></li>
</ol></div>
</p></div>
</p></div>
<p>&#160;</p>
<p>At the moment, although we have based this class on an interface, we are using this in a tightly-coupled fashion in the “BillController” as shown below:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:579020c2-5ed1-45c0-826c-33a9e0e3a294" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">ActionResult</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Lords</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"House"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#60ff60;">&#8220;Lords&#8221;</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"Bills"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">FakeDataRepository</span><span style="background:#181818;color:#e0e0e0;">().</span><span style="background:#181818;color:#fef1a9;">LordsBills</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">ToList</span><span style="background:#181818;color:#e0e0e0;">();</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">View</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#60ff60;">&#8220;Index&#8221;</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">ActionResult</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Commons</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"House"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#60ff60;">&#8220;Commons&#8221;</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"Bills"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">FakeDataRepository</span><span style="background:#181818;color:#e0e0e0;">().</span><span style="background:#181818;color:#fef1a9;">CommonsBills</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">ToList</span><span style="background:#181818;color:#e0e0e0;">();</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">View</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#60ff60;">&#8220;Index&#8221;</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>This is not a good practice to Program to an implementation (Line 4 and Line 10 in Figure). Instead, we should be Programming to an interface and make use loose-coupling where ever applicable. </p>
<h5>Programming to an Interface</h5>
<p>The following code shows the modified BillController that takes in an IDataRepository in it’s constructor. (Lines 5 up to 10 in Figure)</p>
<p>The interface variable “dataRepository” is then used to get the Bills (Line 24 and 30 in Figure)</p>
</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5789b501-27a0-40be-ba0d-0c34a0e42daf" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#8080c0;">namespace</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">JoeBloggsStore</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">Controllers</span></li>
<li><span style="background:#181818;color:#e0e0e0;">{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">class</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">BillController</span><span style="background:#181818;color:#e0e0e0;"> : </span><span style="background:#181818;color:#c7c7f1;">Controller</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">private</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">IDataRepository</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">dataRepository</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">BillController</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#c7c7f1;">IDataRepository</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">repos</span><span style="background:#181818;color:#e0e0e0;">)</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">this</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">dataRepository</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#fef1a9;">repos</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">//</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// GET: /Bill/</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">ActionResult</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Index</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"House"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#60ff60;">&#8220;Parliament&#8221;</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"Bills"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#8080c0;">null</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">View</span><span style="background:#181818;color:#e0e0e0;">();</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">ActionResult</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Lords</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"House"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#60ff60;">&#8220;Lords&#8221;</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"Bills"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#8080c0;">this</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">dataRepository</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">LordsBills</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">ToList</span><span style="background:#181818;color:#e0e0e0;">();</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">View</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#60ff60;">&#8220;Index&#8221;</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">ActionResult</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Commons</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"House"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#60ff60;">&#8220;Commons&#8221;</span><span style="background:#181818;color:#e0e0e0;">;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">ViewData</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"Bills"</span><span style="background:#181818;color:#e0e0e0;">] = </span><span style="background:#181818;color:#8080c0;">this</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">dataRepository</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">CommonsBills</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">ToList</span><span style="background:#181818;color:#e0e0e0;">();</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">View</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#60ff60;">&#8220;Index&#8221;</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">}</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>But, who is going to pass in the correct IDataRepository instance to the BillController. This is where Ninject comes in.</p>
<h5>Integrating Ninject for Constructor Injection</h5>
<p>The BillController depends on an appropriate instance of IDataRepository to be passed when it’s constructed using the constructor. By default, MVC Framework creates an instance of BillController by using a parameterless constructor. In our case, we have want MVC to call our constructor with IDataRepository parameter and pass in the correct instance that we will configure.</p>
<p>To instruct the MVC framework to do this, we have to modify the Global.asax.cs. The default Global.asax.cs file is as follows:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:57b92842-bf7d-4c93-a481-ee4b6534df1c" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#8080c0;">namespace</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">JoeBloggsStore</span></li>
<li><span style="background:#181818;color:#e0e0e0;">{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// Note: For instructions on enabling IIS6 or IIS7 classic mode, </span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// visit http://go.microsoft.com/?LinkId=9394801</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">class</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">MvcApplication</span><span style="background:#181818;color:#e0e0e0;"> : </span><span style="background:#181818;color:#fef1a9;">System</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">Web</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#c7c7f1;">HttpApplication</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">static</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">void</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">RegisterRoutes</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#c7c7f1;">RouteCollection</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">routes</span><span style="background:#181818;color:#e0e0e0;">)</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">routes</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">IgnoreRoute</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#60ff60;">&#8220;{resource}.axd/{*pathInfo}&#8221;</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">routes</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">MapRoute</span><span style="background:#181818;color:#e0e0e0;">(</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;Default&#8221;</span><span style="background:#181818;color:#e0e0e0;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// Route name</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;{controller}/{action}/{id}&#8221;</span><span style="background:#181818;color:#e0e0e0;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// URL with parameters</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> { </span><span style="background:#181818;color:#fef1a9;">controller</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#60ff60;">&#8220;Home&#8221;</span><span style="background:#181818;color:#e0e0e0;">, </span><span style="background:#181818;color:#fef1a9;">action</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#60ff60;">&#8220;Index&#8221;</span><span style="background:#181818;color:#e0e0e0;">, </span><span style="background:#181818;color:#fef1a9;">id</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#60ff60;">&#8220;&#8221;</span><span style="background:#181818;color:#e0e0e0;"> }&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// Parameter defaults</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">protected</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">void</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Application_Start</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">RegisterRoutes</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#c7c7f1;">RouteTable</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">Routes</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">}</span></li>
</ol></div>
</p></div>
</p></div>
<p>&#160;</p>
<p>We need to first make the MvcApplication derive from “Ninject.Framework.Mvc.NinjectHttpApplication” as shown below:</p>
</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e91293e-79a8-4d09-891e-4323c6880d66" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;margin:0 0 0 2em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">class</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">MvcApplication</span><span style="background:#181818;color:#e0e0e0;"> : </span><span style="background:#181818;color:#fef1a9;">Ninject</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">Framework</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">Mvc</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#c7c7f1;">NinjectHttpApplication</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>To do this, we need to add two references to our project. Before that let us copy the two assemblies we need to a “lib” folder inside our Visual Studio solution folder:</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja61.png"><img style="display:inline;border-width:0;" title="Ninja6" border="0" alt="Ninja6" src="http://peakbyte.files.wordpress.com/2009/09/ninja6_thumb1.png?w=554&#038;h=483" width="554" height="483" /></a> </p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja7.png"><img style="display:inline;border-width:0;" title="Ninja7" border="0" alt="Ninja7" src="http://peakbyte.files.wordpress.com/2009/09/ninja7_thumb.png?w=554&#038;h=157" width="554" height="157" /></a> </p>
<p>Let us then add the references:</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja8.png"><img style="display:inline;border-width:0;" title="Ninja8" border="0" alt="Ninja8" src="http://peakbyte.files.wordpress.com/2009/09/ninja8_thumb.png?w=554&#038;h=449" width="554" height="449" /></a> </p>
<p>Upon adding the reference, the NinjectHttpApplication requires us to implement two Abstract members</p>
<ol>
<li>CreateKernel() </li>
<li>RegisterRoutes(RouteCollection) </li>
</ol>
<p>The CreateKernel is where we tell Ninject which Concrete Class needs to be injected when the Constructor of BillController is called.</p>
<p>The RegisterRoutes is where we configure the MVC Routing options. </p>
<p>We need to do two things now:</p>
<ol>
<li>Ensure the Routing still works (because the Application_Start() is now moved into NinjectHttpApplication and RegisterRoutes is also made abstract in NinjectHttpApplication) </li>
<li>Create a configuration that tells Ninject to inject FakeDepository whenever IDataRepository is requested. </li>
</ol>
<p>First, change the RegisterRoutes from being a private method to an overridden protected method&#160; as shown below:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6c467edb-2fc9-4d47-99c8-78a7bbac9e2d" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">protected</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">override</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">void</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">RegisterRoutes</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#c7c7f1;">RouteCollection</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">routes</span><span style="background:#181818;color:#e0e0e0;">)</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">routes</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">IgnoreRoute</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#60ff60;">&#8220;{resource}.axd/{*pathInfo}&#8221;</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">routes</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">MapRoute</span><span style="background:#181818;color:#e0e0e0;">(</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;Default&#8221;</span><span style="background:#181818;color:#e0e0e0;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// Route name</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#60ff60;">&#8220;{controller}/{action}/{id}&#8221;</span><span style="background:#181818;color:#e0e0e0;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// URL with parameters</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> { </span><span style="background:#181818;color:#fef1a9;">controller</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#60ff60;">&#8220;Home&#8221;</span><span style="background:#181818;color:#e0e0e0;">, </span><span style="background:#181818;color:#fef1a9;">action</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#60ff60;">&#8220;Index&#8221;</span><span style="background:#181818;color:#e0e0e0;">, </span><span style="background:#181818;color:#fef1a9;">id</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#60ff60;">&#8220;&#8221;</span><span style="background:#181818;color:#e0e0e0;"> }&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">// Parameter defaults</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);</span></li>
<li>&nbsp;</li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
</ol></div>
</p></div>
</p></div>
<p>&#160;</p>
<p>Now, the configuration to Ninject is provided by creating a Module that derives from&#160; Ninject.Core.StandardModule (There are other modules which we will not delve into now)</p>
<p>The following code shows such a Module:</p>
<p><a href="http://peakbyte.files.wordpress.com/2009/09/ninja9.png"><img style="display:inline;border-width:0;" title="Ninja9" border="0" alt="Ninja9" src="http://peakbyte.files.wordpress.com/2009/09/ninja9_thumb.png?w=335&#038;h=728" width="335" height="728" /></a> </p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a9a07423-8ddc-40a9-883d-859a5c298625" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#8080c0;">namespace</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">JoeBloggsStore</span></li>
<li><span style="background:#181818;color:#e0e0e0;">{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">class</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">WebModule</span><span style="background:#181818;color:#e0e0e0;"> : </span><span style="background:#181818;color:#c7c7f1;">StandardModule</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">override</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">void</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Load</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">Bind</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#c7c7f1;">IDataRepository</span><span style="background:#181818;color:#e0e0e0;">&gt;().</span><span style="background:#181818;color:#fef1a9;">To</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#c7c7f1;">FakeDataRepository</span><span style="background:#181818;color:#e0e0e0;">&gt;().</span><span style="background:#181818;color:#fef1a9;">Using</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#c7c7f1;">OnePerRequestBehavior</span><span style="background:#181818;color:#e0e0e0;">&gt;();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
<li><span style="background:#181818;color:#e0e0e0;">}</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>The Line 7 in above Figure says, “Ninject, please provide one instance of FakeDataRepository per Request whenever IDataRepository is needed”.</p>
<p>We have to now use this WebModule&#160; in CreateKernel function in Global.asax.cs as shown below:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:66068a01-49be-41e8-8d3a-24b49486e28b" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">protected</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">override</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Ninject</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">Core</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#c7c7f1;">IKernel</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">CreateKernel</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c7c7f1;">IModule</span><span style="background:#181818;color:#e0e0e0;">[] </span><span style="background:#181818;color:#fef1a9;">modules</span><span style="background:#181818;color:#e0e0e0;"> = </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">IModule</span><span style="background:#181818;color:#e0e0e0;">[] { </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">AutoControllerModule</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#c7c7f1;">Assembly</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">GetExecutingAssembly</span><span style="background:#181818;color:#e0e0e0;">()), </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">WebModule</span><span style="background:#181818;color:#e0e0e0;">() };</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">return</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">new</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#c7c7f1;">StandardKernel</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#fef1a9;">modules</span><span style="background:#181818;color:#e0e0e0;">);</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
</ol></div>
</p></div>
</p></div>
<p>&#160;</p>
<p>If we try to build and run this code, we might get an error saying “OnePerRequestModule has not been loaded”. </p>
<p>This is because we have told which assembly contains this HttpModule. We can do this in the &lt;httpModules&gt; section of the web.config:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e229b7ee-bc9d-43db-8538-9a7b5441d954" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#5f5fd8;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;httpModules&gt;</span></li>
<li><span style="background:#181818;color:#5f5fd8;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;add </span><span style="background:#181818;color:#c7c7f1;">name</span><span style="background:#181818;color:#5f5fd8;">=</span><span style="background:#181818;color:#60ff60;">&#8220;ScriptModule&#8221;</span><span style="background:#181818;color:#5f5fd8;"> </span><span style="background:#181818;color:#c7c7f1;">type</span><span style="background:#181818;color:#5f5fd8;">=</span><span style="background:#181818;color:#60ff60;">&#8220;System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&#8243;</span><span style="background:#181818;color:#5f5fd8;">/&gt;</span></li>
<li><span style="background:#181818;color:#5f5fd8;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;add </span><span style="background:#181818;color:#c7c7f1;">name</span><span style="background:#181818;color:#5f5fd8;">=</span><span style="background:#181818;color:#60ff60;">&#8220;UrlRoutingModule&#8221;</span><span style="background:#181818;color:#5f5fd8;"> </span><span style="background:#181818;color:#c7c7f1;">type</span><span style="background:#181818;color:#5f5fd8;">=</span><span style="background:#181818;color:#60ff60;">&#8220;System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&#8243;</span><span style="background:#181818;color:#5f5fd8;"> /&gt;</span></li>
<li><span style="background:#181818;color:#5f5fd8;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;add </span><span style="background:#181818;color:#c7c7f1;">name</span><span style="background:#181818;color:#5f5fd8;">=</span><span style="background:#181818;color:#60ff60;">&#8220;OnePerRequestModule&#8221;</span><span style="background:#181818;color:#5f5fd8;"> </span><span style="background:#181818;color:#c7c7f1;">type</span><span style="background:#181818;color:#5f5fd8;">=</span><span style="background:#181818;color:#60ff60;">&#8220;Ninject.Core.Behavior.OnePerRequestModule, Ninject.Core&#8221;</span><span style="background:#181818;color:#5f5fd8;">/&gt;</span></li>
<li><span style="background:#181818;color:#5f5fd8;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;/httpModules&gt;</span></li>
</ol></div>
</p></div>
</p></div>
<p>&#160;</p>
<p>If we run the application now, we should see the application working as expected.</p>
<p>In the future when we want to get the data from a SQL Server database, we can create a new class called SQLDataRepository. The possibilities of SQLDataRepository requiring a connectionString to the database is high. So, this can be configured in the WebModule as follows:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cecbfdff-bbb6-49de-9170-0499cf6997b2" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;font-family:'Courier New', Courier, Monospace;font-size:10pt;">
<div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;">Code Snippet</div>
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#000000;white-space:nowrap;margin:0 0 0 2em;padding:0 0 0 5px;">
<li> <span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#8080c0;">public</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">override</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#8080c0;">void</span><span style="background:#181818;color:#e0e0e0;"> </span><span style="background:#181818;color:#fef1a9;">Load</span><span style="background:#181818;color:#e0e0e0;">()</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#c080c0;">//Bind&lt;IDataRepository&gt;().To&lt;FakeDataRepository&gt;().Using&lt;OnePerRequestBehavior&gt;();</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background:#181818;color:#fef1a9;">Bind</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#c7c7f1;">IDataRepository</span><span style="background:#181818;color:#e0e0e0;">&gt;().</span><span style="background:#181818;color:#fef1a9;">To</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#fef1a9;">SQLDataRepository</span><span style="background:#181818;color:#e0e0e0;">&gt;().</span><span style="background:#181818;color:#fef1a9;">Using</span><span style="background:#181818;color:#e0e0e0;">&lt;</span><span style="background:#181818;color:#c7c7f1;">OnePerRequestBehavior</span><span style="background:#181818;color:#e0e0e0;">&gt;().</span><span style="background:#181818;color:#fef1a9;">WithConstructorArgument</span><span style="background:#181818;color:#e0e0e0;">(</span><span style="background:#181818;color:#60ff60;">&#8220;connectionString&#8221;</span><span style="background:#181818;color:#e0e0e0;">, </span><span style="background:#181818;color:#c7c7f1;">WebConfigurationManager</span><span style="background:#181818;color:#e0e0e0;">.</span><span style="background:#181818;color:#fef1a9;">ConnectionStrings</span><span style="background:#181818;color:#e0e0e0;">[</span><span style="background:#181818;color:#60ff60;">"ApplicationServices"</span><span style="background:#181818;color:#e0e0e0;">]);</span></li>
<li><span style="background:#181818;color:#e0e0e0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></li>
</ol></div>
</p></div>
</p></div>
</p>
<p>The SQLDataRepository’s Constructor should obviously take a connectionstring as parameter for this to work.</p>
<p> The source code for completed web application is available for <a title="Source Code Download" href="http://www.manivannan.org/Resources/BlogFiles/JoeBloggsStore.zip" target="_blank">download</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=185&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2009/09/28/how-to-use-ninject-ioc-with-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja1_thumb.png" medium="image">
			<media:title type="html">Ninja1</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja2_thumb.png" medium="image">
			<media:title type="html">Ninja2</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja3_thumb.png" medium="image">
			<media:title type="html">Ninja3</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja4_thumb.png" medium="image">
			<media:title type="html">Ninja4</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja5_thumb.png" medium="image">
			<media:title type="html">Ninja5</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja6_thumb.png" medium="image">
			<media:title type="html">Ninja6</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/mvc1_thumb.png" medium="image">
			<media:title type="html">MVC1</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/mvc2_thumb.png" medium="image">
			<media:title type="html">MVC2</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/mvc3_thumb.png" medium="image">
			<media:title type="html">MVC3</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/mvc4_thumb.png" medium="image">
			<media:title type="html">MVC4</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/parl1_thumb.png" medium="image">
			<media:title type="html">Parl1</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/parl2_thumb.png" medium="image">
			<media:title type="html">Parl2</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/parl3_thumb.png" medium="image">
			<media:title type="html">Parl3</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/parl4_thumb.png" medium="image">
			<media:title type="html">Parl4</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/mvc5_thumb.png" medium="image">
			<media:title type="html">MVC5</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja6_thumb1.png" medium="image">
			<media:title type="html">Ninja6</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja7_thumb.png" medium="image">
			<media:title type="html">Ninja7</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja8_thumb.png" medium="image">
			<media:title type="html">Ninja8</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2009/09/ninja9_thumb.png" medium="image">
			<media:title type="html">Ninja9</media:title>
		</media:content>
	</item>
		<item>
		<title>TIP: Copy/Paste Columns to Multiple Tables in SQL Server</title>
		<link>http://peakbyte.wordpress.com/2009/09/19/tip-copypaste-columns-to-multiple-tables-in-sql-server/</link>
		<comments>http://peakbyte.wordpress.com/2009/09/19/tip-copypaste-columns-to-multiple-tables-in-sql-server/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 15:29:25 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Problem]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[DB.SQLServer]]></category>
		<category><![CDATA[Tools.SQL]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/?p=141</guid>
		<description><![CDATA[Here is a tip I discovered today while at work. I had earlier postponed the addition of common columns needed for all the tables (columns needed for auditing purposes like AddedDate, AddedBy etc.). But, the time had come now to type in and set the properties for columns on all tables one by one. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=141&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a tip I discovered today while at work. I had earlier postponed the addition of common columns needed for all the tables (columns needed for auditing purposes like AddedDate, AddedBy etc.). But, the time had come now to type in and set the properties for columns on all tables one by one. I finished adding these columns to the first table. When on the second table, my laziness kicked in and wanted an easier way to do this mundane task. So,</p>
<ol>
<li>Opened the design of table1 using SQL Server Management Studio.</li>
<li>Selected the last 4 columns.</li>
<li>Ctrl+C.</li>
<li>Opened the design view of table2</li>
<li>Ctrl+V</li>
</ol>
<p>And there it was, all the columns along with the properties replicated in a jiffy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=141&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2009/09/19/tip-copypaste-columns-to-multiple-tables-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>
	</item>
		<item>
		<title>Expression Blend 3 + SketchFlow + Dynamic Prototyping</title>
		<link>http://peakbyte.wordpress.com/2009/08/03/expression-blend-3-sketchflow-dynamic-prototyping/</link>
		<comments>http://peakbyte.wordpress.com/2009/08/03/expression-blend-3-sketchflow-dynamic-prototyping/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 13:03:00 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[KM.Design]]></category>
		<category><![CDATA[Tools.Design]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/2009/08/03/expression-blend-3-sketchflow-dynamic-prototyping/</guid>
		<description><![CDATA[One word: Incredible! The Background: I’ve got the privilege to work on a Greenfield project which involves: Collecting and Analysing Requirements Web Application Designing (not Graphic/Web Designing) Implementing Testing Deploying and Going live As in my previous projects, it is the first task that takes a lot of time and effort. In my previous projects, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=139&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One word: Incredible!</p>
<p>The Background: </p>
<p>I’ve got the privilege to work on a Greenfield project which involves:</p>
<ul>
<li>Collecting and Analysing Requirements </li>
<li>Web Application Designing (not Graphic/Web Designing) </li>
<li>Implementing </li>
<li>Testing </li>
<li>Deploying and Going live </li>
</ul>
<p>As in my previous projects, it is the first task that takes a lot of time and effort. In my previous projects, I’ve never overlooked the Use Case Analysis and has thus resulted in completing the projects on time and to the stakeholder’s satisfaction.</p>
<p>I have, in the past, effectively communicated my understanding of “&quot;WHAT” needs to be done in the project by providing a <a href="http://office.microsoft.com/en-gb/powerpoint/default.aspx" target="_blank">PowerPoint</a> presentation. In one case, I earned both the confidence and the trust of my Project Manager. Such is the importance of effectively communicating what I have understood to the stakeholder. While, PowerPoint is sufficient for small projects, with complicated ones, I’ve often found something missing in my arsenal. I intended to learn sketching on paper as a profession, but never found the time to.</p>
<p>But, now there is a prototyping/sketching tool available in the set of software products that I own. Thanks to my attendance at <a href="http://www.microsoft.com/uk/remix08/" target="_blank">ReMix UK 2008</a> where I got a 1 year <a href="http://expression.microsoft.com/en-us/subscriptions/default.aspx" target="_blank">subscription</a> to Microsoft Expression Suite and related software. A couple of weeks ago, Microsoft Expression 3 was released and in there was the new “<a href="http://www.microsoft.com/expression/products/Blend_Overview.aspx" target="_blank">Blend 3 + SketchFlow</a>”.</p>
<p>Never realised how influential <a href="http://www.billbuxton.com/" target="_blank">Bill Buxton</a>, from whom I bought a signed copy of his “<a href="http://www.amazon.co.uk/Sketching-User-Experiences-Interactive-Technologies/dp/0123740371" target="_blank">Sketching User Experiences</a>” book, would be. The default font used in the <a href="http://www.microsoft.com/expression/products/Sketchflow_Overview.aspx" target="_blank">SketchFlow</a> is named “Buxton Sketch”!</p>
<p>I have realised that despite being a non-designer, there is nothing stopping me from sketching the product design well ahead even before coding. That way, as proved in my past experiences, I can focus on “How to do” armed with a list of “What to do”.</p>
<p>I’ve started learning SketchFlow using an excellent sample chapter from the book “<a href="http://www.dynamic-prototyping.com/" target="_blank">Dynamic Prototyping</a>”. The language used by the author in this book is simply great. The book does not feed the reader with all detailed steps. It invites the reader to observe and try to implement the features as shown in the figures in the book. This, to me is the first of such experiences. That way, the reading does not get boring and keeps the reader on toes. I can’t wait for the book to be released.</p>
<p>The most impressive of this <a href="http://www.dynamic-prototyping.com/071009_Dynamic_Prototyping.pdf" target="_blank">sample chapter</a> is that it covers almost many basic things that as a developer I would need to get started with SketchFlow. Here is a gist:</p>
<ol>
<li>Understanding Blend 3 workspace for SketchFlow </li>
<li>Working with SketchFlow Map </li>
<li>Importing freehand drawings and creating own content </li>
<li>Sharing Sketches and getting Feedback (this one rocks!) </li>
<li>Animation </li>
<li>Navigation </li>
<li>States </li>
<li>Sampling Data </li>
<li>Components </li>
<li>Annotations </li>
<li>Creating Documentation of the SketchFlow </li>
</ol>
<p>After having completed this sample chapter, I am confident of now creating sketches to show to my new project’s stakeholder. Hopefully, I won’t meet him because the SketchFlow Player (which is essentially a <a href="http://silverlight.net/default.aspx" target="_blank">Silverlight</a> application) enables all possible basic scenarios to obtain feedback from the stakeholder while working remotely. Once I publish my sketchflow in a secure location online for my stakeholder to view, then begins the impressive process of refining requirements and use cases.</p>
<p>The step after that would be to create User Stories for the minimal Scrum based project management tool <a href="http://scrumy.com" target="_blank">Scrumy</a>.</p>
<p>Then with the great online repository of <a href="http://www.unfuddle.com" target="_blank">Unfuddle</a>, I should be unfuddling in no time at all to implement the project. </p>
<p>Expecting an exciting August month.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=139&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2009/08/03/expression-blend-3-sketchflow-dynamic-prototyping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>
	</item>
		<item>
		<title>Remote access of SQL Server from Host Machine</title>
		<link>http://peakbyte.wordpress.com/2008/12/17/remote-access-of-sql-server-from-host-machine/</link>
		<comments>http://peakbyte.wordpress.com/2008/12/17/remote-access-of-sql-server-from-host-machine/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 12:41:46 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Problem]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[DB.SQLServer]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/2008/12/17/remote-access-of-sql-server-from-host-machine/</guid>
		<description><![CDATA[How to access SQL Server 2008 express running in a Virtual PC remotely from Host PC.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=91&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I use Vista running on a Virtual PC as my development environment (I used to use WinXP, but then came along Windows Azure which required either Vista or Win Server 2003). The usage of SQL Server Management Studio on the Virtual PC was slowing down the system. So, I wanted to use my Host Operating System to access the SQL Server using SQL Management Studio. By default the SQL Server engine is configured to minimise the surface of attack. So, remote access to the sql server engine is also not enabled. </p>
<p>To access remotely, the TCP/IP protocol needs to be enabled, using the SQL Server Configuration Manager.</p>
<p><a href="http://peakbyte.files.wordpress.com/2008/12/tmpdc50.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="125" alt="tmpDC50" src="http://peakbyte.files.wordpress.com/2008/12/tmpdc50-thumb.png?w=244&#038;h=125" width="244" border="0"></a></p>
<p>There after, it is recommended to allow remote connections via specified ports. So, I did that as shown below.</p>
<p><a href="http://peakbyte.files.wordpress.com/2008/12/tmp69c1.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="244" alt="tmp69C1" src="http://peakbyte.files.wordpress.com/2008/12/tmp69c1-thumb.png?w=219&#038;h=244" width="219" border="0"></a></p>
<p>To test the configuration, I used a command from the remote computer.</p>
<p><a href="http://peakbyte.files.wordpress.com/2008/12/tmpe7c9.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="125" alt="tmpE7C9" src="http://peakbyte.files.wordpress.com/2008/12/tmpe7c9-thumb.png?w=244&#038;h=125" width="244" border="0"></a></p>
<p>Thumbs up. There were no error messages displayed after executing the above command</p>
<p>I expected a nice little text box in the SQL Server Management Studio connection dialog where I could specify the TCP/IP port number. It turns out there isn&#8217;t and that I could simply append the port number in the same way I tested from command line.</p>
<p><a href="http://peakbyte.files.wordpress.com/2008/12/tmp87c1.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="185" alt="tmp87C1" src="http://peakbyte.files.wordpress.com/2008/12/tmp87c1-thumb.png?w=244&#038;h=185" width="244" border="0"></a></p>
<p>That&#8217;s it, a little burden outsourced to the Host PC.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=91&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2008/12/17/remote-access-of-sql-server-from-host-machine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2008/12/tmpdc50-thumb.png" medium="image">
			<media:title type="html">tmpDC50</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2008/12/tmp69c1-thumb.png" medium="image">
			<media:title type="html">tmp69C1</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2008/12/tmpe7c9-thumb.png" medium="image">
			<media:title type="html">tmpE7C9</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2008/12/tmp87c1-thumb.png" medium="image">
			<media:title type="html">tmp87C1</media:title>
		</media:content>
	</item>
		<item>
		<title>Start SQL Server from Command Line</title>
		<link>http://peakbyte.wordpress.com/2008/12/16/start-sqlexpress-from-command-line/</link>
		<comments>http://peakbyte.wordpress.com/2008/12/16/start-sqlexpress-from-command-line/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 12:39:24 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Problem]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[DB.SQLServer]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/2008/12/16/start-sqlexpress-from-command-line/</guid>
		<description><![CDATA[I run a Virtual PC with Vista 32-bit as Guest operating system for my software development purposes. This VPC is quite slow despite taking measures to shut down various background services. For reasons beyond my understanding (and me not willing to investigate on it), whenever a MMC console window is opened, CPU usage spikes to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=77&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I run a Virtual PC with Vista 32-bit as Guest operating system for my software development purposes. This VPC is quite slow despite taking measures to shut down various background services.</p>
<p>For reasons beyond my understanding (and me not willing to investigate on it), whenever a MMC console window is opened, CPU usage spikes to 100%. It was frustrating to to start SQL Server Engine by going to the services.msc console. So, I found a way to start SQL Server service from command line.</p>
<p>&nbsp;<a href="http://peakbyte.files.wordpress.com/2008/12/tmpe0b41.png" target="_blank"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="44" alt="tmpE0B4" src="http://peakbyte.files.wordpress.com/2008/12/tmpe0b4-thumb1.png?w=244&#038;h=44" width="244" border="0"></a></p>
<p>Please click on above image to see the command in clarity.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=77&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2008/12/16/start-sqlexpress-from-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>

		<media:content url="http://peakbyte.files.wordpress.com/2008/12/tmpe0b4-thumb1.png" medium="image">
			<media:title type="html">tmpE0B4</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ-SQL Nuggeting</title>
		<link>http://peakbyte.wordpress.com/2008/12/16/linq-sql-nuggeting/</link>
		<comments>http://peakbyte.wordpress.com/2008/12/16/linq-sql-nuggeting/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 11:54:18 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Solution]]></category>
		<category><![CDATA[Lang.LINQ]]></category>
		<category><![CDATA[Lang.SQL]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/2008/12/16/linq-sql-nuggeting/</guid>
		<description><![CDATA[On my recent project, I had to help my co-developer get an understanding of LINQ-SQL (Yes, I am aware that LINQ-SQL has been shelved by M$). I remembered the brilliant MSDN Nuggets that were produced by the evangelist teams here in Microsoft UK. These were helpful short videos organised by tags based on technology/interests. They [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=72&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On my recent project, I had to help my co-developer get an understanding of LINQ-SQL (Yes, I am aware that LINQ-SQL has been shelved by M$).</p>
<p>I remembered the brilliant MSDN Nuggets that were produced by the evangelist teams here in Microsoft UK. These were helpful short videos organised by tags based on technology/interests. They are even now hosted in MSDN UK web site. But, they have a search facility instead of the earlier tags/categories. I generally don&#8217;t lend myself to searching on MSDN despite it insisting &#8220;live search&#8221; with green coloured attractions. So, felt a bit disappointed at the difficulty in locating nuggets for a specific technology/interest.</p>
<p>I just opted to view all the nuggets by <a href="http://mtaulty.com" target="_blank">Mike Taulty</a>. Eventually picked up the list of nuggets for LINQ-SQL that might be of immediate help to my co-developer.</p>
<ol>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/223/Introduction-to-LINQ-to-SQL.aspx" target="_blank">Introduction to LINQ-SQL</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/222/Understanding-the-DataContext.aspx" target="_blank">Understanding Data Context</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/221/Mapping-Schemas-to-Classes-in-LINQ-to-SQL.aspx" target="_blank">Mapping Schemas to Classes</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/219/Inserts-with-LINQ-to-SQL.aspx" target="_blank">Inserting data</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/218/Deletes-with-LINQ-to-SQL.aspx" target="_blank">Deleting</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/217/Updates-with-LINQ-to-SQL.aspx" target="_blank">Updating</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/215/Joining-Data-with-LINQ-to-SQL.aspx" target="_blank">Joins with LINQ-SQL</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/214/Working-with-NULLs-in-LINQ-to-SQL.aspx" target="_blank">Working with NULLs</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/213/When-Do-LINQ-to-SQL-Queries-Execute.aspx" target="_blank">Understanding When queries execute</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/212/Deferred-Loading-of-Related-Entities-in-LINQ-to-SQL.aspx" target="_blank">Deferred loading of related entities</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/211/Querying-with-Stored-Procedures-in-LINQ-to-SQL.aspx" target="_blank">Querying wth Stored procs</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/210/Updating-with-Stored-Procedures-in-LINQ-to-SQL.aspx" target="_blank">Updating with Stored Procs</a></li>
<li><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/206/Transactions-in-LINQ-to-SQL.aspx" target="_blank">Transactions</a></li>
</ol>
<p>Hope that helps my friend to get up to speed with this project.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=72&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2008/12/16/linq-sql-nuggeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>
	</item>
		<item>
		<title>Tapovanam &#8211; application design and architecture</title>
		<link>http://peakbyte.wordpress.com/2008/10/02/tapovanam-application-design-and-architecture/</link>
		<comments>http://peakbyte.wordpress.com/2008/10/02/tapovanam-application-design-and-architecture/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 09:28:56 +0000</pubDate>
		<dc:creator>Manimaran</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Problem]]></category>
		<category><![CDATA[Arch.Web]]></category>

		<guid isPermaLink="false">http://peakbyte.wordpress.com/2008/10/02/tapovanam-application-design-and-architecture/</guid>
		<description><![CDATA[In redesigning and redeveloping Tapovanam&#8217;s (my friend&#8217;s organisation) web site, I want to put in place a good architecture. The following are some of the considerations: A multi-tier design (mainly to separate presentation code from business logic) Support themes in presentation layer to switch designs easily at later stage. Object oriented business logic layer (BLL) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=70&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In redesigning and redeveloping Tapovanam&#8217;s (my friend&#8217;s organisation) web site, I want to put in place a good architecture. The following are some of the considerations:</p>
<ul>
<li>A multi-tier design (mainly to separate presentation code from business logic)
<li>Support themes in presentation layer to switch designs easily at later stage.
<li>Object oriented business logic layer (BLL) (with business objects)
<li>Data access layer (DAL) to be independent of underlying database (to switch databases or even use XML files as data store at a later time)
<li>Data Transfer Objects (DTO) to pass data between BLL and DAL
<li>Maximum use of Data Binding at the presentation layer </li>
</ul>
<p>Following are few ideas in mind at this moment to solve the above problems:</p>
<p><u>Multi-tier Design</u></p>
<p>Presentation Layer &#8211; ASP.NET Web Forms</p>
<p>Business Logic Layer &#8211; C# business objects having all the validation logic and an abstracted view of underlying data schema.</p>
<p>Data Access Layer &#8211; C# data access classes to retrieve and store data in data transfer objects</p>
<p><u>Plug-in model for Data Access</u></p>
<p>To be able to change or use multiple data stores with least effort, the Data Access Layer will use the Provider Model design pattern. </p>
<p>An <em>abstract base</em> class containing common data access methods like ExecuteNonQuery, ExecuteReader will be used. This methods in this <em>abstract base</em> class serve as Helper methods for data access. (similar to Data Access Application Block in Enterprise Library). This could be named as <strong>DataAccess</strong></p>
<p>For each module in the web site (Eg.. Photos, Events, Commentaries), an <em>abstract provider</em> class and a <em>concrete</em> class is created. </p>
<p>The <em>abstract provider</em> class will have abstract CRUD (create, retrieve, update, delete) methods which will be implemented by the <em>concrete</em> class. For example, GetPhoto(), GetPhotosByCategory() etc. This class is data store agnostic. This could be named as <strong>PhotoProvider</strong></p>
<p>The <em>concrete</em> class will have the data store specific method implementations defined in the <em>abstract provider</em>. This could be named as <strong>SqlPhotoProvider</strong></p>
<p><u>Data Transfer Object</u></p>
<p>To transfer objects with data between BLL and DAL, separate classes are created. For example, <em>PhotoDetails</em> class to store the Photo record obtained from data store. Using un-typed DataSets as DTOs is problematic when it comes to maintenance (spelling mistakes are a pain)</p>
<p>A collection (like List&lt;T&gt;) of DTOs is used to pass a set of retrieved data from data store to BLL.</p>
<p><u>Object Oriented BLL</u></p>
<p>The business logic layer consists of C# classes that represent the business objects. These classes have all the validation logic, business logic and methods that talk to the DAL. These classes also use the respective Data Transfer Objects to pass and retrieve data from DAL. These classes can be named like <em>Photo</em>, <em>Event </em>etc.</p>
<p><u>DataBinding in Presentation Layer</u></p>
<p>To databind UI components like ListView, GridView, DetailsView etc. the ObjectDataSource controls are used in the aspx pages. The ObjectDataSource controls use the Business Objects in BLL and facilitate as binding adapters between the aspx page and business objects.</p>
<p>Other considerations include :</p>
<ul>
<li>Using all the existing ASP.NET built-in <a href="http://msdn.microsoft.com/en-us/library/aa479030.aspx" target="_blank">Provider</a> services like Membership, Profile, Health Monitoring and Personalisation
<li>Using <a href="http://www.codeplex.com/entlib" target="_blank">Enterprise Library&#8217;s</a> Data Access, Exception, Logging, Security blocks.
<li><a href="https://www.paypal.com/IntegrationCenter/ic_sdk-resource.html" target="_blank">Pay-pal</a> integration for <a href="http://dashcommerce.org/" target="_blank">e-shop</a>
<li>Globalisation and Localisation to display web site in Indian Language
<li>Content managed pages (allow contributors to compose and publish pages) </li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peakbyte.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peakbyte.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peakbyte.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peakbyte.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peakbyte.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peakbyte.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peakbyte.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peakbyte.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peakbyte.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peakbyte.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peakbyte.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peakbyte.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peakbyte.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peakbyte.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peakbyte.wordpress.com&amp;blog=5176588&amp;post=70&amp;subd=peakbyte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peakbyte.wordpress.com/2008/10/02/tapovanam-application-design-and-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9ac5605b52bf05be4d0eca669dc9571b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peakbyte</media:title>
		</media:content>
	</item>
	</channel>
</rss>
