<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3614688564147648057</id><updated>2012-02-16T09:41:08.774-08:00</updated><category term='Premier League'/><category term='Regional Language'/><category term='Mobile'/><category term='Visual Studio'/><category term='Red Devils'/><category term='Website'/><category term='Indian Quizzing League'/><category term='Machester United'/><category term='Pergola'/><category term='Standards'/><category term='VHD'/><category term='Quizzing'/><category term='Review'/><category term='SQL Server'/><category term='Berbatov'/><category term='Code Contracts'/><category term='Pidgin'/><category term='VS 2010'/><category term='How to'/><category term='Null Pattern'/><category term='Restaurant'/><category term='Symbian'/><category term='Hindi'/><category term='VPC'/><category term='Chat'/><category term='EPL'/><category term='Hotel'/><category term='Enterprise Library'/><category term='Database'/><category term='Parallel programming'/><category term='Chennai'/><category term='Astoria'/><category term='Software'/><category term='ADO.NET Data Services'/><category term='Umbraco'/><category term='IM'/><category term='.NET'/><title type='text'>Technocratica - Plebeian Crucibles</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-2687587335395351465</id><published>2011-06-13T22:51:00.001-07:00</published><updated>2011-06-13T22:51:31.416-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Umbraco'/><title type='text'>Designing with Umbraco : XSLT vs User Controls</title><content type='html'>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;in Jan, I wrote my first post on Umbraco and how to build a simple Hello World page using Umbraco.&amp;#160; Having spent the last few months working on Umbraco, I have to say, my liking for Umbraco has only grown. It is a fairly simple CMS and unlike Sharepoint, does not complicate the whole authoring experience. You could always argue that Sharepoint is comprehensive but that’s a discussion we will save for another post. &lt;/p&gt;  &lt;p align="justify"&gt;Back to what you can do with Umbraco, there are really two major options as an Umbraco developer to build UI; XSLT and User Controls. A lot of times as a developer, the decision you have to make is which way to go. As with a lot of other design discussions, the perfect answer is “It Depends”. But during the course of this post, I will try and unravel that generic answer to some realistic scenarios. I am going to try and layout the factors that I usually consider when deciding one way or the other. Keep in mind that this post is written targeting the web form model of Umbraco and&amp;#160; come razor, some of these could change.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;&lt;u&gt;XSLT&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p align="justify"&gt;XSLT is the in-thing when it comes to content managed sites. It gives you the option of giving flexibility to the content author to change the way the page is displayed making it truly content managed.&lt;/p&gt;  &lt;p align="justify"&gt;With umbraco, you get the option of using XSLT to do almost everything you want. I have typically used the following constructs to decide if XSLT is the best fit&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Fluctuating UI Changes&lt;/strong&gt; -&amp;#160; You think something is going to change often. A typical scenario is where you have HTML tags emitted within the macro. Though there are ways and means of getting the styling changed with css, there are times when you have no choice but to emit HTML. XSLT is a natural choice in such scenarios&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Navigate Content Tree&lt;/strong&gt;- If you have to work with the Umbraco content tree. Since the Umbraco content tree is XML, XSLT becomes a natural choice if you have to navigate through the content tree. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Compliance to Standards – &lt;/strong&gt;There are a lot of content managed standards that are prevalent. Standards like DITA are becoming more of a requirement nowadays when authoring sites. A lot of these CMS standards depend on XML and XSLT.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;When in Doubt – &lt;/strong&gt;Yes. We all come across instances when we are not sure whether to use XSLT or user controls. In such cases, my recommendation will be to start off with XSLT unless you hit an implementation roadblock that forces you to change to User Controls.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;User Controls&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p align="justify"&gt;User controls are the most natural choice for most .NET developers because they relate to it better due to their familiarity with .NET. But with XSLT being so powerful, the use of user controls for me, is limited to the following scenarios&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Code Abstraction – &lt;/strong&gt;When you do not want site managers or authors to see the code. A valid argument is that the permissions to viewing XSLT can be restricted as well through the User Permissions but bear in mind that XSLT is file based in Umbraco so users who have permissions to access the XSLT folder can view, copy or do anything with the code. If you do not want users to see what your code is doing, stick to the user control model.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Interaction with external web services&lt;/strong&gt; – This is one of the scenarios for which I still use User control. Theoretically, it is still possible to write an XSLT extension that talks to the web service and use that within XSLT but I think it is beneficial only in scenarios where you are using the strong points of XSLT. One more interesting approach when using webservices is to use javascript and jquery templates. You could completely eliminate a macro in this scenario by having the webservice return JSON. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Parallelism – &lt;/strong&gt;If you want to write muti-threaded code or use PLINQ then you do that only with user controls; so they become a forced choice&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Use ASP.NET Features -&lt;/strong&gt;&amp;#160; Though this looks like a no-brainer, the caveat here is that you can still access some of the features from XSLT. The umbraco.library does have methods to get the query string or the form variables. But if you want to check if a page is posted back or not, you cannot do that in XSLT without doing some hacks.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Unit Testing Requirements – &lt;/strong&gt;If your project requires to have high code coverage then move away from XSLT.Though there are XSLT Unit Testing suites, they are still nascent and wont really improve your code coverage results.&lt;/p&gt;  &lt;p align="justify"&gt;Though the above list might not be exhaustive, I have tried to cover scenarios in my experience with Umbraco so far. I will be interested in knowing if there are any scenarios that you have come across that isn’t covered in this post and if you agree\disagree to the observations made in this post.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-2687587335395351465?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/2687587335395351465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2011/06/designing-with-umbraco-xslt-vs-user.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/2687587335395351465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/2687587335395351465'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2011/06/designing-with-umbraco-xslt-vs-user.html' title='Designing with Umbraco : XSLT vs User Controls'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-3681573292007510698</id><published>2010-11-16T19:15:00.001-08:00</published><updated>2010-11-17T07:02:56.172-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Umbraco'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>My first page with Umbraco</title><content type='html'>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:78b2d991-73da-4bcd-ba6c-f4c5a35b8632" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Umbraco" rel="tag"&gt;Umbraco&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CMS" rel="tag"&gt;CMS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ASP.NET" rel="tag"&gt;ASP.NET&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;After a small Diwali break, I am back to my blogging. The focus of this post is going to be a CMS from MS called Umbraco. I came to know about Umbraco from one of my friends. Having been involved in developing and designing a few content managed websites, I decided to take a deeper look into Umbraco. It is just a week since I started playing around with it but I thought I will get started off about creating a first page with Umbraco as I delve into other advanced aspects and figure out how to get it done.&lt;/p&gt;  &lt;p align="justify"&gt;For the unfamiliars, &lt;a href="http://umbraco.org/" target="_blank"&gt;Umbraco&lt;/a&gt; is an ASP.NET based CMS. You can install Umbraco by using the web platform installer. The installation is fairly easy and self-explanatory. After you have installed it, launching Umbraco will give you the admin log in page. Use the credentials you used during set up to log in. Your home page will look like below&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_2cIm7h7Xp2w/TONIopJ8bJI/AAAAAAAAAOg/gIsummDieRA/s1600-h/image3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_2cIm7h7Xp2w/TONIpaT2ZyI/AAAAAAAAAOk/SlorSb5o838/image_thumb1.png?imgmax=800" width="494" height="286" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Settings is where to start off creating the first page. Clicking&amp;#160; on Settings will reveal the tree view that shows the building blocks that we will use to build our site. Let us focus on Templates and Document Types for a second. These are the two most important artifacts we will use to come up with a content managed page. For those of you familiar with Sharepoint, Templates are like Master Pages and Document Types are like Page Layouts. &lt;/p&gt;  &lt;p align="justify"&gt;The first step in creating a site is to get the master page and the style sheets done. Since Umbraco is a folder based CMS, you should be able to copy your existing Stylesheets to the stylesheet folder under the Umbraco virtual directory and you are good to go. Though it does work for the master pages to some extent, I had a bit of an issue getting Umbraco to recognise the master pages I had copied. So, I create the master page through the Umbraco interface. You have to right click on &lt;strong&gt;Templates&lt;/strong&gt; and then Click on &lt;strong&gt;Create&lt;/strong&gt;. Once you provide the name and confirm the creation, you will have the ability to add HTML content to the master page. The interface will look as shown below&lt;/p&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_2cIm7h7Xp2w/TONIqMvVgbI/AAAAAAAAAOo/U3MP9TI8Emo/s1600-h/image%5B4%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_2cIm7h7Xp2w/TONIrBW4irI/AAAAAAAAAOs/lnwMcYQD3_U/image_thumb%5B1%5D.png?imgmax=800" width="517" height="299" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Umbraco, by itself creates a nested master page. You just have to put in your content. Since it is a nested master page, be sure you put the content inside your content place holder (in my case called “ContentPlaceHolderDefault”). You will also see that you have the option of using one of your own master pages as the parent master page.&lt;/p&gt;  &lt;p align="justify"&gt;Once the master page is done, the next step is to go ahead and create a document type that we will use to put in content. Its quite easy to create a document type. You just right click and say Create. &lt;/p&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_2cIm7h7Xp2w/TONIsLBKq2I/AAAAAAAAAOw/JQjmaAAOe4k/s1600-h/image%5B9%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_2cIm7h7Xp2w/TONIs_zOXeI/AAAAAAAAAO0/23CSuDFOKhk/image_thumb%5B4%5D.png?imgmax=800" width="398" height="231" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p align="justify"&gt;Give a name for the Document Type and select the Template that this document type will use. You can change this later too so don’t worry too much about selecting the wrong master page. &lt;/p&gt;  &lt;p align="justify"&gt;The document type is where most of the work happens to make a page content managed. There are four tabs for every document type you create.&amp;#160; The first tab is the Info tab where all the details of the document type are displayed. You can provide an alias and associate the document type with an image. You can also set what Master Pages this document type can use and what is the default Master Page for this document type. Below is an example of the HomePage document type I created.&lt;/p&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_2cIm7h7Xp2w/TONItmXlWuI/AAAAAAAAAO4/asrnapDutig/s1600-h/image%5B14%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_2cIm7h7Xp2w/TONIubETSAI/AAAAAAAAAO8/-KiFGvwp7O4/image_thumb%5B7%5D.png?imgmax=800" width="507" height="294" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Next, let us examine the Tabs tab. In this tab, you can create tabs that will be displayed when this document type is used to create content. To show how it works, I have created a tab called Content that will hold the rich text box for the content author to put in the content. &lt;/p&gt;  &lt;p align="justify"&gt;The next step is to let the document type know that it has to display a rich text box in the Content tab. You do this by creating a property of type Rich text box in the Generic Properties tab under Content. &lt;/p&gt;  &lt;p align="justify"&gt;As you can see in the screenshot, I have created a “HelloWorldContent” property of type rich text box. You can also create properties of various other types. These types are essentially controls. Do note that the alias is like the HTML id of the control. You can also set if the content in this is mandatory and what regular expressions can be used to validate the content but we will save that for later. Now that the document type is created and we have created a rich text control as a part of the document type, we have to let the master page know where to display the content of the rich text box. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_2cIm7h7Xp2w/TONIu6pNw6I/AAAAAAAAAPA/jMJRrHMdh6Y/s1600-h/image%5B19%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_2cIm7h7Xp2w/TONIv8ZRdVI/AAAAAAAAAPE/EDFGmjo2X8U/image_thumb%5B10%5D.png?imgmax=800" width="516" height="299" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;This can be done by inserting a page filed in the master page. Go back to the Master Page and click on Insert Page field in the tool bar above the master page. The below window will open up. If you have created the property right, then you should see it in the Choose Field dropdown. Select the field and leave the other fields to default. Save the master page.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_2cIm7h7Xp2w/TONIweBMUsI/AAAAAAAAAPI/9hNKpTUtskA/s1600-h/image%5B24%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_2cIm7h7Xp2w/TONIxbz2guI/AAAAAAAAAPM/G2nsrsNFQGE/image_thumb%5B13%5D.png?imgmax=800" width="452" height="262" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;We are done with the administration part. The final step in creating a page is the content authoring page. All content authoring in Umbraco is done in the Content screen. Click on Content in the Sections area. Right Click on the top level Content and click on Create. This pulls up a window with a text box for naming your page and a dropdown with the list of created Document Types. Choose the document type you just created and give the page a name. In my case, I choose to call it HomePage. Post creation, you will see two tabs Content and Properties as seen below. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_2cIm7h7Xp2w/TOPumZkhDTI/AAAAAAAAAPY/qv1NVxO1Fow/s1600-h/image%5B4%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_2cIm7h7Xp2w/TOPuncHXV-I/AAAAAAAAAPc/j7e21xzL294/image_thumb%5B1%5D.png?imgmax=800" width="686" height="396" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;The order in which they are displayed depends on the Sort Order I have set in the Tabs tab of the document type. The content author can put in any content in the rich text box and publish the page by clicking the Save and Publish icon. As soon as you publish, Umbraco generates a URL which you can view in the Properties tab. The page that I have created is shown below&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_2cIm7h7Xp2w/TONIyvnwTyI/AAAAAAAAAPQ/xStUreKrpYw/s1600-h/image%5B28%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_2cIm7h7Xp2w/TONIzYperdI/AAAAAAAAAPU/DH1HK13LAkM/image_thumb%5B15%5D.png?imgmax=800" width="507" height="293" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Phew!!! That was quite a long post. I am sure this is the first of many to come from me on Umbraco. If you want to to get adventurous with Umbraco too, take a look at their site. For starters I found this &lt;a href="http://www.blogfodder.co.uk/2010/5/13/building-your-first-umbraco-site-from-scratch" target="_blank"&gt;site&lt;/a&gt; too very useful. Please feel free to leave your comments on this post and as always, Happy Coding!!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-3681573292007510698?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/3681573292007510698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/11/my-first-page-with-umbraco.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/3681573292007510698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/3681573292007510698'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/11/my-first-page-with-umbraco.html' title='My first page with Umbraco'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_2cIm7h7Xp2w/TONIpaT2ZyI/AAAAAAAAAOk/SlorSb5o838/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-333034818017171962</id><published>2010-09-22T01:00:00.001-07:00</published><updated>2010-09-22T01:02:34.526-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Standards'/><title type='text'>HTML5.Decode</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0fabc7a1-2550-4beb-992b-c61bc951823c" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/HTML5" rel="tag"&gt;HTML5&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTML" rel="tag"&gt;HTML&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTML+4+vs+HTML+5" rel="tag"&gt;HTML 4 vs HTML 5&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;Most of us would have heard that HTML 5 is in the works. It can be expected that almost all new browsers (some of the browsers already do) will now start supporting HTML5. What does it mean for developers and architects? This post will take a look at HTML 5 and some of the new elements in HTML 5. Detailed insights into the working of individual elements is out of scope for this particular post but I have provided links to references wherever necessary&lt;/p&gt;  &lt;p align="justify"&gt;1. Standards: One of the biggest changes in HTML 5 is that it is no longer based upon SGML. Though this does not impact developers or the architect community directly, it is good to know this because the HTML document no longer needs a DTD to render. So the !DOCTYPE element is now redundant. However, this element now performs a different function. It actually tells the browser if the document has to comply to standards or not. You can do this by setting the DOCTYPE to either of the three allowed modes; quirks mode, limited quirks mode and no quirks mode.&lt;/p&gt;  &lt;p align="justify"&gt;2. New Elements: HTML 5 has introduced a lot of new HTML elements. The new elements fall into one (sometimes multiple) of the below categories&lt;/p&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Sectioning – Sectioning can internally be divided into root and content. Root is a type of element that can have children under it. One of the new sectioning root element in HTML 5 is &lt;a href="http://dev.w3.org/html5/html-author/#the-figure-element" target="_blank"&gt;&amp;lt;figure&amp;gt;&lt;/a&gt;&lt;strong&gt;.&amp;#160; &lt;/strong&gt;&lt;a href="http://www.w3.org/TR/html5/interactive-elements.html#the-details-element" target="_blank"&gt;&amp;lt;detail&amp;gt;&lt;/a&gt; is another sectioning root element that is new on the block. The &amp;lt;detail&amp;gt; element lets you hide details unless the user wants to view them explicitly. For example, you are showing only the name of the user and you want to show the details only if the user clicks on a button or a link. The sectioning content category contains new elements like &amp;lt;nav&amp;gt;, &amp;lt;article&amp;gt; and &amp;lt;section&amp;gt;. While &lt;a href="http://www.w3.org/TR/html5/sections.html#the-nav-element" target="_blank"&gt;&amp;lt;nav&amp;gt;&lt;/a&gt; identifies sections intended for navigation (similar to a sitemap), &amp;lt;section&amp;gt; and &amp;lt;article&amp;gt; isolate elements in a HTML Page. &lt;a href="http://www.w3.org/TR/html5/sections.html#the-article-element" target="_blank"&gt;&amp;lt;article&amp;gt;&lt;/a&gt;, for example, is intended for something like a blog entry which can be distributed independently. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Heading – The heading category introduces &lt;a href="http://www.w3.org/TR/html5/sections.html#the-header-element" target="_blank"&gt;&amp;lt;header&amp;gt;&lt;/a&gt; and &lt;a href="http://www.w3.org/TR/html5/sections.html#the-hgroup-element" target="_blank"&gt;&amp;lt;hgroup&amp;gt;&lt;/a&gt; tags. While there were already 6 header tags &amp;lt;h1&amp;gt; to &amp;lt;h6&amp;gt;, you can now wrap them inside the newly introduced &amp;lt;header&amp;gt; and &amp;lt;hgroup&amp;gt; tags. While the &amp;lt;header&amp;gt; tag identifies something as a header section, the &amp;lt;hgroup&amp;gt; tag can be used to categorise the 6 header tags as subsections.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Embedded Content – In HTML 4, we used the object tag to display video or play audio. In HTML 5, we have separate tags to embed audio or video in the page. &lt;a href="http://www.w3.org/TR/html5/video.html#video" target="_blank"&gt;&amp;lt;video&amp;gt;&lt;/a&gt; and &lt;a href="http://www.w3.org/TR/html5/video.html#audio" target="_blank"&gt;&amp;lt;audio&amp;gt;&lt;/a&gt; tags do exactly this. Apart from these tags, there is also the &lt;a href="http://www.w3.org/TR/html5/the-iframe-element.html#the-embed-element" target="_blank"&gt;&amp;lt;embed&amp;gt;&lt;/a&gt; tag that helps you embed any other plug in. One of the more important embedded elements is also the &lt;a href="http://www.w3.org/TR/html5/the-canvas-element.html#the-canvas-element" target="_blank"&gt;&amp;lt;canvas&amp;gt;&lt;/a&gt; that helps you display graphics or dynamic images.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Phrasing Content – These are the HTML elements that can include normal text mark up. &amp;lt;span&amp;gt; is an example of phrasing content. &lt;a href="http://www.w3.org/TR/html5/text-level-semantics.html#the-mark-element" target="_blank"&gt;&amp;lt;mark&amp;gt;&lt;/a&gt; is a new phrasing element in HTML 5. This is like the highlight text is MS Word. Using mark you can highlight text in a document for example, search results. &lt;a href="http://www.w3.org/TR/html5/the-button-element.html#the-progress-element" target="_blank"&gt;&amp;lt;progress&amp;gt;&lt;/a&gt; element helps you show progress bar. There are other Phrasing elements like &lt;a href="http://www.w3.org/TR/html5/text-level-semantics.html#the-time-element" target="_blank"&gt;&amp;lt;time&amp;gt;&lt;/a&gt; which help you show timestamps on your page. There is also the &amp;lt;datalist&amp;gt; element which now helps you create re-usable list options in your page.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Menus and Commands – Though both the &lt;a href="http://www.w3.org/TR/html5/interactive-elements.html#menus" target="_blank"&gt;&amp;lt;menu&amp;gt;&lt;/a&gt; element and &lt;a href="http://www.w3.org/TR/html5/interactive-elements.html#the-command" target="_blank"&gt;&amp;lt;command&amp;gt;&lt;/a&gt; element are phrasing content, I have called them out separately because of the significant differences from the previous version. &amp;lt;menu&amp;gt; element,&amp;#160; which was deprecated in HTML 4 has been reintroduced in HTML 5. The menu element can now be enhanced using the &amp;lt;command&amp;gt; element. The &amp;lt;command&amp;gt; element allows the user to execute commands specified as a part of the element.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;3. New Attributes: HTML 5 has also introduced a whole set of new attributes to existing elements. One of the most significant additions is to our favorite &amp;lt;input&amp;gt; tag. The type attribute of the &amp;lt;input&amp;gt; tag now has some new additions. Some of these are search, month, date etc. See &lt;a href="http://www.w3.org/TR/html5/states-of-the-type-attribute.html" target="_blank"&gt;here&lt;/a&gt; for the complete list of new values.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The &lt;a href="http://www.w3.org/TR/html5/the-map-element.html#the-area-element" target="_blank"&gt;&amp;lt;area&amp;gt;&lt;/a&gt; element now has a host of new attributes. I am listing some of them below&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;       &lt;div align="justify"&gt;ping – this attribute contains a list of space separated URLs that are pinged when the URL is clicked. This is useful for content targeting and can be turned on or off by the user.&lt;/div&gt;     &lt;/li&gt;      &lt;li&gt;       &lt;div align="justify"&gt;media – This attribute is similar to the media attribute in the link element. This is again used to specify the type of media a link targets&lt;/div&gt;     &lt;/li&gt;      &lt;li&gt;       &lt;div align="justify"&gt;hreflang and rel – Again, these do the same function as in a link element. &lt;/div&gt;     &lt;/li&gt;      &lt;li&gt;       &lt;div align="justify"&gt;target – this attribute which was deprecated has been re-introduced.&lt;/div&gt;     &lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;     &lt;div align="justify"&gt;There is now an autofocus attribute to elements like &amp;lt;input&amp;gt; and &amp;lt;select&amp;gt;. This will declaratively set the focus on the control when the page loads. This is something the user can turn off if he does not want to use.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;There is a required attribute to the &amp;lt;input&amp;gt; element which validates mandatory fields.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;A new form attribute for text element inputs help the developer specify which form the specific element belongs to. This way, it is not necessary that all the elements lie within a form. They can be placed outside the form but still be a part of it in the HTML DOM.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;You can now disable validation of a form by using the novalidate attribute in the form element.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;The individual input elements now have attributes like formaction, formtarget which overrides the value set in the form tag. This way, a single page can submit to multiple targets declaratively&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;You can now write scoped style sheets by using&amp;#160; the scoped attribute of the style element. for example, if you want the style to be applied only to a specific scope like one flow section, you can mention that by setting the scoped attribute to true.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Developers also have more control over when a particular script is being executed by using the async and the defer attributes in the script element. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;The iframe element has a set of new attributes that controls how the content within the iframe behave. Using the &lt;a href="http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox" target="_blank"&gt;sandbox&lt;/a&gt; attribute, for example, you can now restrict users from clicking links or executing active content within an iframe. There is now also a &lt;a href="http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-srcdoc" target="_blank"&gt;srcdoc&lt;/a&gt; attribute using which you can specify the source of an iframe to be a document with a valid DOCTYPE&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Some HTML attributes have now been upgraded to &lt;a href="http://www.w3.org/TR/html5/elements.html#global-attributes" target="_blank"&gt;global attributes&lt;/a&gt; which means they will now be available across all the elements. Examples of such attributes are class, id, lang, dir etc. There are also new global attributes and event handlers in the list. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;The draggable attribute is more powerful and can be used in conjunction with the new drag &amp;amp; drop APIs in HTML 5&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;4. Absent Elements: Some of the defunct elements are frame, frameset, acronym, applet, font&lt;/p&gt;  &lt;p align="justify"&gt;I will conclude this particular post here. Please be advised that HTML 5 is still being developed and some of the above may change. You can always find the latest reference to HTML 5 specifications &lt;a href="http://www.w3.org/TR/html5/" target="_blank"&gt;here&lt;/a&gt;. One of the things that has not been covered as part of this post are the HTML APIs and the changes in these APIs. Hopefully I will come out with another post that concentrates on the HTML 5 APIs. Till then ciao and happy coding!!!&lt;/p&gt;  &lt;div align="justify"&gt;&lt;/div&gt;  &lt;ul&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-333034818017171962?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/333034818017171962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/09/html5decode.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/333034818017171962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/333034818017171962'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/09/html5decode.html' title='HTML5.Decode'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8586339272747534658</id><published>2010-08-30T10:20:00.001-07:00</published><updated>2010-08-30T10:25:44.966-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Library'/><title type='text'>Enterprise Library 5.0 – Configuration Services Part - III</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:eb731a0b-cd54-49ad-8fe6-8d6a20473148" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/enterprise+Library+5.0" rel="tag"&gt;enterprise Library 5.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/parentSource" rel="tag"&gt;parentSource&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;The previous two posts on Configuration Services showed &lt;a href="http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-50-configuration.html"&gt;how we can use an external configuration file&lt;/a&gt; and how &lt;a href="http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-configuration.html"&gt;we can use a specific section from an external config source&lt;/a&gt;. &lt;/p&gt;  &lt;p align="justify"&gt;In the final post of the Configuration Sources series, we will look at what I personally think is one of the most useful features of Configuration Services. We will see how we can have the application configuration file inherit from another configuration file and override or add only sections that are application specific.  I will give you a  scenario where this can be very useful.&lt;/p&gt;  &lt;p align="justify"&gt;In one of my recent projects we were developing a number of websites. Except for some application specific key value pairs a lot of the other environmental configurations were the same across most of these websites.  With this feature, it will be very easy to isolate the environmental specific values in a separate configuration file, inherit the same and add key value pairs to store application specific values.&lt;/p&gt;  &lt;p align="justify"&gt;To show how this works, I have a shared config file that looks like the below. &lt;/p&gt;  &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;section&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="loggingConfiguration"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;requirePermission&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="true"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;connectionStrings&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;configSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=""&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;     &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;connectionStrings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;loggingConfiguration&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=""&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;tracingEnabled&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="true"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;defaultCategory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="General"&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;listeners&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="EntLIbTestListener"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;listenerDataType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;source&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Enterprise Library Logging"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;formatter&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Text Formatter"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;log&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=""&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;machineName&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="."&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;traceOutputOptions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="None"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;listeners&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;formatters&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;template&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Timestamp: {timestamp}{newline}&amp;amp;#xA;Message: {message}{newline}&amp;amp;#xA;Category: {category}{newline}&amp;amp;#xA;Priority: {priority}{newline}&amp;amp;#xA;EventId: {eventid}{newline}&amp;amp;#xA;Severity: {severity}{newline}&amp;amp;#xA;Title:{title}{newline}&amp;amp;#xA;Machine: {localMachine}{newline}&amp;amp;#xA;App Domain: {localAppDomain}{newline}&amp;amp;#xA;ProcessId: {localProcessId}{newline}&amp;amp;#xA;Process Name: {localProcessName}{newline}&amp;amp;#xA;Thread Name: {threadName}{newline}&amp;amp;#xA;Win32 ThreadId:{win32ThreadId}{newline}&amp;amp;#xA;Extended Properties: {dictionary({key} - {value}{newline})}"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Text Formatter"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum19" style="color:#606060;"&gt;  19:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;formatters&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum20" style="color:#606060;"&gt;  20:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;categorySources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum21" style="color:#606060;"&gt;  21:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;switchValue&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="All"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="General"&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum22" style="color:#606060;"&gt;  22:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;listeners&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum23" style="color:#606060;"&gt;  23:&lt;/span&gt;                     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="EntLIbTestListener"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum24" style="color:#606060;"&gt;  24:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;listeners&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum25" style="color:#606060;"&gt;  25:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum26" style="color:#606060;"&gt;  26:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;categorySources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum27" style="color:#606060;"&gt;  27:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;specialSources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum28" style="color:#606060;"&gt;  28:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;allEvents&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;switchValue&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="All"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="All Events"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum29" style="color:#606060;"&gt;  29:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;notProcessed&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;switchValue&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="All"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Unprocessed Category"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum30" style="color:#606060;"&gt;  30:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;errors&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;switchValue&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="All"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Logging Errors &amp;amp;amp; Warnings"&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum31" style="color:#606060;"&gt;  31:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;listeners&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum32" style="color:#606060;"&gt;  32:&lt;/span&gt;                     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="EntLIbTestListener"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum33" style="color:#606060;"&gt;  33:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;listeners&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum34" style="color:#606060;"&gt;  34:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;errors&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum35" style="color:#606060;"&gt;  35:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;specialSources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum36" style="color:#606060;"&gt;  36:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;loggingConfiguration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum37" style="color:#606060;"&gt;  37:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p align="justify"&gt;This is the same configuration as I have used in Part I and II with the logging settings. To use this as my parent configuration, I have to set a couple of properties. I have to set the Parent Source of my config file to the common config file I have created above. The settings are shown in the screenshot below. I have also changed the  configuration source to be System Configuration which means my local app.config is being used.&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_2cIm7h7Xp2w/THvoOXfwpWI/AAAAAAAAAN8/xuCgLEvUczY/s1600-h/Parentconfig%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Parentconfig" border="0" alt="Parentconfig" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/THvoO7UnKsI/AAAAAAAAAOA/ZmSksMtfgaI/Parentconfig_thumb%5B2%5D.jpg?imgmax=800" width="356" height="231" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p align="justify"&gt;Notice how this configuration file does not have any logging settings. After these changes, my config file now looks like&lt;/p&gt;&lt;br /&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;br /&gt;   &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="1.0"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;section&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="enterpriseLibrary.ConfigurationSource"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;requirePermission&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="true"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;enterpriseLibrary.ConfigurationSource&lt;/span&gt; selectedSource="System Configuration Source"&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;         parentSource="Shared Config"&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;sources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="System Configuration Source"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Shared Config"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;filePath&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="C:\Users\r.vaideeswaran\Documents\Visual Studio 2010\Projects\EntLibTest\EntLibTest\CommonConfig.config"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;sources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;enterpriseLibrary.ConfigurationSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Notice how there are now two sources added; one is the system configuration source and the other points to the shared configuration file.&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;As a first step, let me now test the logging code I wrote in the previous two parts. For re-cap, here is the code&lt;/p&gt;&lt;br /&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;br /&gt;   &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; EntLibTest1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Program&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;         {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;             LogWriter textWriter = EnterpriseLibraryContainer.Current.GetInstance&amp;lt;LogWriter&amp;gt;();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;             LogEntry testEntry = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; LogEntry();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;             testEntry.Message = &lt;span style="color:#006080;"&gt;"Logging the loading of EntLibTest1"&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;             testEntry.Priority = 2;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;             testEntry.Categories.Add(&lt;span style="color:#006080;"&gt;"General"&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;             textWriter.Write(testEntry);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;             Console.WriteLine(&lt;span style="color:#006080;"&gt;"Message Logged"&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;             Console.ReadLine();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;         }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;     }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: normal; "&gt;This does indeed produce a “Message Logged” output on the console though there are no logging sections directly in my config. This tells me that my parent source is working. The next step is now to add a specific section and see if that works.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I add a new key value pair in the appSettings section through enterprise library. The screenshot for the same is as below.&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_2cIm7h7Xp2w/THvoPgA-gmI/AAAAAAAAAOE/HJ2jHXMgq30/s1600-h/image%5B4%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_2cIm7h7Xp2w/THvoQiJ2AJI/AAAAAAAAAOI/xIxexPtL2dY/image_thumb%5B2%5D.png?imgmax=800" width="430" height="294" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;This is our good old appSettings key value pair. Unsurprisingly, the config is now changed to reflect the above settings.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;span class="Apple-style-span" style="line-height: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;  &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="1.0"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;section&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="enterpriseLibrary.ConfigurationSource"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;requirePermission&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="true"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;appSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="ConnectionString"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TestConnectionString"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;appSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;enterpriseLibrary.ConfigurationSource&lt;/span&gt; selectedSource="System Configuration Source"&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;         parentSource="Shared Config"&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;sources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="System Configuration Source"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Shared Config"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;filePath&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="C:\Users\r.vaideeswaran\Documents\Visual Studio 2010\Projects\EntLibTest\EntLibTest\CommonConfig.config"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;sources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;enterpriseLibrary.ConfigurationSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;To make sure my app can retrieve the appSettings value, I add the following three lines of codev(Do not forget the usings at the top)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;  1:&lt;/span&gt; AppSettingsReader connReader = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; AppSettingsReader();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;  2:&lt;/span&gt; var connString = connReader.GetValue(&lt;span style="color:#006080;"&gt;"ConnectionString"&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;  3:&lt;/span&gt; Console.WriteLine(connString.ToString());&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Nothing fancy. Now when I run the application, you will see that the application picks up both the logging configuration and the appSettings key. This happens because at run time the Enterprise library merges the two configuration files so that they act as one. The above example did not specifically override a section but if I were to override, the value in the local configuration will take precedence over the shared configuration.&lt;br /&gt;&lt;br /&gt;That concludes my three part starter posts on Configuration Services. The Configuration Services is no where near perfect yet but as with anything else, I am sure this will evolve over multiple releases. Happy Coding!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8586339272747534658?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8586339272747534658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-50-configuration_30.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8586339272747534658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8586339272747534658'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-50-configuration_30.html' title='Enterprise Library 5.0 – Configuration Services Part - III'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2cIm7h7Xp2w/THvoO7UnKsI/AAAAAAAAAOA/ZmSksMtfgaI/s72-c/Parentconfig_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-5989253713815827126</id><published>2010-08-19T11:09:00.001-07:00</published><updated>2010-08-19T11:13:02.066-07:00</updated><title type='text'>Enterprise Library 5.0 – Configuration Services Part -II</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:32dccb5e-1e21-4b6b-ab8c-24b176d86d8a" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Enterprise+Library+5.0" rel="tag"&gt;Enterprise Library 5.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Configuration+Services" rel="tag"&gt;Configuration Services&lt;/a&gt;,&lt;a href="http://technorati.com/tags/configSource" rel="tag"&gt;configSource&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;Last week, we saw how to use the same configuration file for two different applications. If you have not read the post yet, you can read it &lt;a href="http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-50-configuration.html"&gt;here&lt;/a&gt;. This week, we will look at how configuration services can help you use a section from a shared configuration file. For the sake of continuity, I will use the same example we used in the previous post.&lt;/p&gt;  &lt;p align="justify"&gt;In the previous post, we added a separate logging section, the change here is that we will just add a redirected section in the Configuration Sources element itself. To enable section redirection, the following has to be done&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Change the configuration source to System Configuration Source. This will enable the application to use its default app.config&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Add a redirected section. You can do this by expanding the Configuration Sources section and then add a redirected section. The source of the configuration section should now point to the section in the external file. The screenshot below shows how to add a redirected section&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_2cIm7h7Xp2w/TG1zSoY3INI/AAAAAAAAANo/oLHHBwSn500/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/TG1zTLncUWI/AAAAAAAAANs/_zEz7gheNi8/image_thumb%5B3%5D.png?imgmax=800" width="399" height="279" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;div align="justify"&gt; &lt;/div&gt;  &lt;p align="justify"&gt;The configuration file now looks like the below&lt;/p&gt;  &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="1.0"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;section&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="enterpriseLibrary.ConfigurationSource"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;requirePermission&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="true"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;enterpriseLibrary.ConfigurationSource&lt;/span&gt; selectedSource="System Configuration Source"&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;sources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="System Configuration Source"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Shared Config"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;                 &lt;span style="color:#ff0000;"&gt;filePath&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="C:\Users\r.vaideeswaran\Documents\Visual Studio 2010\Projects\EntLibTest\logging.config"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;sources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;redirectSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;sourceName&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Shared Config"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="loggingConfiguration"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;redirectSections&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;enterpriseLibrary.ConfigurationSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Note how the logging is now configured as a redirectSection. This will ensure that the logging section is picked up from the shared config file. The code in the previous post will now work with this configuration as well without any changes. For the sake of reference, below is the code &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;br /&gt;   &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Program&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;         LogWriter textWriter = EnterpriseLibraryContainer.Current.GetInstance&amp;lt;LogWriter&amp;gt;();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;         LogEntry testEntry = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; LogEntry();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;         testEntry.Message = &lt;span style="color:#006080;"&gt;"Logging the loading of EntLibTest1"&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;         testEntry.Priority = 2;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;         testEntry.Categories.Add(&lt;span style="color:#006080;"&gt;"General"&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;         textWriter.Write(testEntry);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;         Console.WriteLine(&lt;span style="color:#006080;"&gt;"Message Logged"&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;         Console.ReadLine();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;     }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;While in theory, this is the same as using the configSource for a particular setting, one of the advantages is that configSource doesnt permit you to use absolute paths (except for appSettings where you can use the file attribute instead of configSource). Sometimes, this can be a real pain. The Ent Lib Configuration Sources solves that problem.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Hope I was able to give you an idea of how to use a redirected section with Ent Lib 5.0. Happy Coding!!!!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-5989253713815827126?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/5989253713815827126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-configuration.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/5989253713815827126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/5989253713815827126'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-configuration.html' title='Enterprise Library 5.0 – Configuration Services Part -II'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2cIm7h7Xp2w/TG1zTLncUWI/AAAAAAAAANs/_zEz7gheNi8/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8166313481546974405</id><published>2010-08-08T07:45:00.001-07:00</published><updated>2010-08-08T08:35:35.162-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Library'/><title type='text'>Enterprise Library 5.0 – Configuration Services Part - I</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5752d232-0587-479d-a7e7-e4bd9244b41d" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Enterprise+Library+5.0" rel="tag"&gt;Enterprise Library 5.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Configuration+Services" rel="tag"&gt;Configuration Services&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;Microsoft recently released Ent Lib 5.0. While most of the application blocks are the same as 4.1, one of the new kids on the block is Configuration Services. Hence, I will start off this series on Ent Lib 5.0 by taking a closer look at the Configuration Services.&lt;/p&gt;  &lt;p align="justify"&gt;The configuration services provides three capabilities when it comes to managing config files&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Ability for multiple applications to use the same config file&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Ability to use of a specific section from a shared config file&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Ability for a configuration file to inherit from another config file&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In this post, we will see how to enable multiple applications to share the same config file.&lt;/p&gt;  &lt;h3&gt;&lt;u&gt;Multiple Applications using the Same Config File&lt;/u&gt;&lt;/h3&gt;  &lt;p align="justify"&gt;I will start off by creating a simple console application. For first timers, right click on the config and you should see a context menu to edit enterprise library configuration.&lt;/p&gt;  &lt;p&gt;Clicking on the menu brings up the Ent Lib configuration console. The console has been re-designed in the latest version of enterprise library.  To add a configuration source section, there is a menu called “Add Configuration Settings” under Blocks menu. Click on it and you should see a Configuration Section now added. Click on the  &lt;a href="http://lh3.ggpht.com/_2cIm7h7Xp2w/TF7DEDyozCI/AAAAAAAAANY/Blv7hSBWqt0/s1600-h/image%5B11%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/TF7DFA0_gLI/AAAAAAAAANc/zahd3KVvqh0/image_thumb%5B7%5D.png?imgmax=800" width="23" height="18" /&gt;&lt;/a&gt; icon to expand the section and add a File Based Configuration Source. &lt;/p&gt;  &lt;p align="justify"&gt;Provide the values of the config name and the path of the config file. In the selected source dropdown, select the shared source that we have just configured. Save the settings and right click on the Configuration Sources section and click on Validate. You will get the list of warnings and errors, if any. Let us take a moment to look at the changes in the config. The following section has been added under the &amp;lt;configuration&amp;gt; section&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;lt;configSections&amp;gt;    &lt;br /&gt; &amp;lt;section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /&amp;gt;     &lt;br /&gt;&amp;lt;/configSections&amp;gt; &lt;/p&gt;    &lt;p&gt;&amp;lt;enterpriseLibrary.ConfigurationSource selectedSource="Common Config"&amp;gt;    &lt;br /&gt; &amp;lt;sources&amp;gt;     &lt;br /&gt;   &amp;lt;add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&amp;gt;     &lt;br /&gt;   &amp;lt;add name="Common Config" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"     &lt;br /&gt;     filePath="CommonConfig" /&amp;gt;     &lt;br /&gt; &amp;lt;/sources&amp;gt;     &lt;br /&gt;&amp;lt;/enterpriseLibrary.ConfigurationSource&amp;gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="justify"&gt;When you close the enterprise library console, you should now see a commonconfig.config file in your project path. Right click and include the same in your project. Make sure you change the property of the file to copy over to the output path. This will now be the configuration that your application now uses. &lt;/p&gt;  &lt;p&gt;To test this, I have added a logging application block and used the following code to log an entry into the event log.&lt;/p&gt;  &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; LogWriter textWriter = EnterpriseLibraryContainer.Current.GetInstance&amp;lt;LogWriter&amp;gt;();&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt; LogEntry testEntry = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; LogEntry();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt; testEntry.Message = &lt;span style="color:#006080;"&gt;"Logging the loading of EntLibTest"&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt; testEntry.Priority = 2;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt; testEntry.Categories.Add(&lt;span style="color:#006080;"&gt;"General"&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt; textWriter.Write(testEntry);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum7"  style="color:#606060;"&gt;   7:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum8"  style="color:#606060;"&gt;   8:&lt;/span&gt; Console.WriteLine(&lt;span style="color:#006080;"&gt;"Message Logged"&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum9"  style="color:#606060;"&gt;   9:&lt;/span&gt; Console.ReadLine();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;Do remember to make the appropriate configuration changes to ensure logging is enabled. Running the application creates an entry in the event log. I now add another project to the same solution and update the configuration source to point to the commonconfig.config of the first project. Below is a snapshot of how my config for the second project looks like.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_2cIm7h7Xp2w/TF7DGDk_CFI/AAAAAAAAANg/dyY-YtSIVIE/s1600-h/image%5B21%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/TF7DG7MQsZI/AAAAAAAAANk/AvV-7gsLDgs/image_thumb%5B13%5D.png?imgmax=800" width="302" height="142" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p align="justify"&gt;You should be able to run the application without making any other changes and ensure that messages are logged from the second console application as well. &lt;/p&gt;&lt;p align="justify"&gt;Before all you web developers get excited, please remember that this feature does not work with web applications just yet. You can see the details of why in this &lt;a href="http://www.dotnetforthoughts.com/post/2010/06/30/BUG-External-configuration-source-file-in-Enterprise-Library-5.aspx"&gt;blog&lt;/a&gt;. &lt;/p&gt;&lt;p align="justify"&gt;That concludes our first look at Configuration Services in Enterprise Library 5.0. I will dig into the other two aspects in subsequent posts. Happy Coding!!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8166313481546974405?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8166313481546974405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-50-configuration.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8166313481546974405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8166313481546974405'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/08/enterprise-library-50-configuration.html' title='Enterprise Library 5.0 – Configuration Services Part - I'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2cIm7h7Xp2w/TF7DFA0_gLI/AAAAAAAAANc/zahd3KVvqh0/s72-c/image_thumb%5B7%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-3480753873745109978</id><published>2010-07-19T11:56:00.001-07:00</published><updated>2010-07-19T11:56:28.553-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>Code Generation with VS 2010</title><content type='html'>&lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9da28b7f-bdd7-466b-914e-0b3d5f8d6c88" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VS+2010" rel="tag"&gt;VS 2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Code+Generation" rel="tag"&gt;Code Generation&lt;/a&gt;,&lt;a href="http://technorati.com/tags/UML" rel="tag"&gt;UML&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Architecture" rel="tag"&gt;Architecture&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;Have been off for quite some time, so its good to be back&amp;#160; blogging. I will start off with a relatively light post. &lt;/p&gt;  &lt;p align="justify"&gt;All of us know that you can create Architectural Diagrams in VS 2010 using the architecture menu. But once, you have done creating the diagrams how do you actually make the diagrams generate code? The last thing you want to do is to create the diagrams and write the code for it manually. &lt;/p&gt;  &lt;p align="justify"&gt;Though VS 2010 does not have built in support for code generation, you can have it generate code by downloading and installing &lt;a href="http://msdn.microsoft.com/en-us/vstudio/ff655021.aspx"&gt;Visualisation and Modelling Feature Pack&lt;/a&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Once you download and install the feature pack from the link above, there are a couple of small things you have to do to get your diagrams ready for code generation. The first thing is to set a profile to your model. i.e tell the model which language to generate code.&lt;/p&gt;  &lt;p align="justify"&gt;You can do this by viewing the properties of the model explorer. You should see an attribute called Stereotypes as shown in the diagram below. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_2cIm7h7Xp2w/TESfyavJG7I/AAAAAAAAANA/SPUdp2XOoCk/s1600-h/image%5B4%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/TESfzUvkNlI/AAAAAAAAANE/EmFBujJhtdQ/image_thumb%5B2%5D.png?imgmax=800" width="379" height="322" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;Select C# namespace. As you can see, the whole code generation works on T4. So if you want to have code generated in SQL for example you could just write your text transformation templates and you should be ready to go.&lt;/p&gt;  &lt;p align="justify"&gt;Actually, there is a very good blog &lt;a href="http://www.olegsych.com/2010/01/uml-modeling-and-code-generation-in-visual-studio-2010/"&gt;here&lt;/a&gt; on how exactly to write your own T4 templates for code generation. &lt;/p&gt;  &lt;p align="justify"&gt;Once you have done that, you can then configure how your classes and namespaces should be named and organised. You do this by clicking on Architecture-&amp;gt; Configure Default code generation settings. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_2cIm7h7Xp2w/TESf0Hc4dFI/AAAAAAAAANI/mM7gZvX70W4/s1600-h/image%5B13%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/TESf09rWeVI/AAAAAAAAANM/WIuqsDLLFa4/image_thumb%5B7%5D.png?imgmax=800" width="317" height="178" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Beware, by default, the namespace is always the name of the model so be wary when you name the model because once you set it, you will not be able to change it. You should now be ready to start generating code. Right click on your modelling diagram and you should see a generate code menu as shown. You can set the path under which you want the class to be generated here. &lt;/p&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_2cIm7h7Xp2w/TESf10YFO4I/AAAAAAAAANQ/6E9GEKKLoJg/s1600-h/image%5B9%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_2cIm7h7Xp2w/TESf2yQ8LcI/AAAAAAAAANU/SurxAOlXxLI/image_thumb%5B5%5D.png?imgmax=800" width="412" height="248" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-3480753873745109978?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/3480753873745109978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/07/code-generation-with-vs-2010.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/3480753873745109978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/3480753873745109978'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/07/code-generation-with-vs-2010.html' title='Code Generation with VS 2010'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2cIm7h7Xp2w/TESfzUvkNlI/AAAAAAAAANE/EmFBujJhtdQ/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-7533753152161264676</id><published>2010-01-01T10:05:00.001-08:00</published><updated>2010-01-01T10:08:33.568-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>Working with Hierarchical data in SQL Server 2008</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:542fbb9e-c7d4-47b4-9aaa-46db01419f13" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/HierarchyId" rel="tag"&gt;HierarchyId&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CTEs" rel="tag"&gt;CTEs&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;In my series on SQL Server 2008, one of the features I had missed was the HierarchyId datatype and its usage. I came across this recently and decided to take a peek into what it does. This post covers my thoughts on the HierarchyId datatype.&lt;/p&gt;  &lt;p align="justify"&gt;At the time of this writing, I am still not convinced on the value add the HierarchyId datatype provides over traditional parent/child storage mechanisms. More on that later. For now, we will deal with how the datatype works and how it can be used to store hierarchial data.&lt;/p&gt;  &lt;p align="justify"&gt;The big advantage with HierarchyId is that it is optimised to store data in a tree structure thereby making it simpler for developers to query and update hierarchical information.&amp;#160; The important thing to keep in mind is that using the hierarchyid by itself does not mean that data is stored in a tree structure. It is the responsibility of the application to make sure that the data is stored in the desired structure. HierarchyId just acts as an enabler. &lt;/p&gt;  &lt;p align="justify"&gt;To demonstrate this, I will work through an example where we have to store the list of folders and files in the database. I have created a table with the following structure. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Create Table FileExplorer      &lt;br /&gt;(       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ItemId HierarchyId Primary Key,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ItemLevel as ItemId.GetLevel(),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ItemName varchar(100)&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="justify"&gt;I will touch upon the ItemLevel column later. Do note that the HierarchyId datatype by itself is not unique. It is application’s responsibility again to maintain the uniqueness of the ItemId column and hence I have declared a PrimaryKey on that column.&lt;/p&gt;  &lt;p align="justify"&gt;Coming to ItemLevel column, the primary purpose of that is to enable breadth first ordering. Typically, hierarchy ids can be breadth first or depth first indexed. You can find the details and working of both these types of ordering &lt;a href="http://msdn.microsoft.com/en-us/library/bb677268(SQL.105).aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Now, let us create the breadth first index. Depending on how many levels (called fan-outs) you plan to store, your indexing strategy will vary. It is not necessary to create both the indexes for all the scenarios.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;CREATE INDEX FileExplorer_Breadth_First      &lt;br /&gt;ON FileExplorer(ItemLevel,ItemId)       &lt;br /&gt;GO&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="justify"&gt;Since the FileExplorer table already has a Primary key, the above index will be created as a non-clustered index. &lt;/p&gt;  &lt;p align="justify"&gt;Now that we have created the table, let us start loading data into the table. If you haven’t already noted, let me point out that the ItemId is not declared as an Identity (it cannot be, actually) and hence it is the application’s responsibility again to make sure that the generated ids are unique. In addition, to ensure the tree structure, we have to make sure the id generated is based on the parent id. &lt;/p&gt;  &lt;p align="justify"&gt;The stored procedure to insert a new file or folder is &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;CREATE PROCEDURE InsertFile(@folderId hierarchyid, @ItemName nvarchar(100) )      &lt;br /&gt;AS       &lt;br /&gt;BEGIN       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DECLARE @last_child hierarchyid &lt;/p&gt;    &lt;p&gt;SELECT @last_child = MAX(ItemId) FROM FileExplorer      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE ItemId.GetAncestor(1) = @folderId       &lt;br /&gt;INSERT FileExplorer (ItemId, ItemName)       &lt;br /&gt;SELECT @folderId.GetDescendant(@last_child, NULL), @ItemName       &lt;br /&gt;END ;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;Let us examine this procedure for a second.&amp;#160; The ItemId.GetAncestor(1) gets the immediate parent of the ItemId. So essentially, the select statement gets&amp;#160; the last valid file under the given folder id. Now that we have the last inserted item under the parent, our new file has to be created as a peer to that item.&lt;/p&gt;  &lt;p align="justify"&gt;This is done by the second select statement in the procedure. We use the GetDescendant method to create a child similar to another child, in this case, the item retrieved from the previous select. It wouldn’t be out of place to mention here that this is where our breadth first ordering helps. &lt;/p&gt;  &lt;p align="justify"&gt;The tree can also be maintained by creating a parentId column that references the itemId but there is also a performance drag associated with that approach. A snapshot of the data after inserting some rows is as below&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_2cIm7h7Xp2w/Sz45acWix3I/AAAAAAAAAL8/T_NCOER2onY/s1600-h/Results%5B6%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Results" border="0" alt="Results" src="http://lh3.ggpht.com/_2cIm7h7Xp2w/Sz45bFPE64I/AAAAAAAAAMA/FsSam6WrgE0/Results_thumb%5B4%5D.jpg?imgmax=800" width="517" height="203" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Note how the item level computes itself. The folders testFolderChild and TestfolderChildPeer are at the same level and have the same parent –TestFolder. &lt;/p&gt;  &lt;p align="justify"&gt;Let us now see how we can retrieve the list of parents for a given node. To do this, I had to write a stored procedure using CTEs. Below is the stored procedure I wrote&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;create proc dbo.GetAncestors(@ItemId hierarchyId)     &lt;br /&gt;as      &lt;br /&gt;begin &lt;/p&gt;    &lt;p&gt;With AncestorsList(Itemid, ItemName, ItemLevel, Parent)     &lt;br /&gt;As      &lt;br /&gt;(      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Select ItemId, ItemName, ItemLevel, ItemId.GetAncestor(1) as Parent from Fileexplorer where ItemId=@ItemId      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; UNION ALL      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Select fe.ItemId, fe.ItemName, fe.ItemLevel, fe.Itemid.GetAncestor(1) from FileExplorer fe Inner Join AncestorsList al       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ON fe.ItemId = al.Parent      &lt;br /&gt;)&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Select fe.ItemId, fe.ItemName, fe.ItemLevel from FileExplorer fe INNER JOIN      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; AncestorsList al on fe.ItemId = al.Itemid       &lt;br /&gt;end&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;If you are familiar with CTEs then most of the code above is self explanatory. My anchor members gets the first ancestor of the given node. This is then executed recursively by my recursive query. The last select executes the CTE to return the resultset.&lt;/p&gt;  &lt;p align="justify"&gt;Having seen most of the uses of HierarchyId, its biggest drawback lies in the fact that it still needs the developers to do a lot. For fan-outs of less that 2 levels, I still feel the self referencing table is faster than using the hierarchyId. I strongly believe that Microsoft still has some work left to do with the HierarchyId datatype to make sure it is a bit more easier to implement. &lt;/p&gt;  &lt;p align="justify"&gt;That though concludes this post. If you are looking to work with HierarchyIds, I hope this post has given you an idea of where to start. Hope to be back soon with something else. Happy Coding!!!!!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-7533753152161264676?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/7533753152161264676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/01/working-with-hierarchical-data-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/7533753152161264676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/7533753152161264676'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2010/01/working-with-hierarchical-data-in-sql.html' title='Working with Hierarchical data in SQL Server 2008'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_2cIm7h7Xp2w/Sz45bFPE64I/AAAAAAAAAMA/FsSam6WrgE0/s72-c/Results_thumb%5B4%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8050162892970302266</id><published>2009-12-12T07:37:00.001-08:00</published><updated>2009-12-12T07:50:03.861-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>.NET 4.0 and VS 2010 Series – Dynamic Features</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a63389c3-2bc1-4b91-b35c-dc239f2475e4" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Dynamic" rel="tag"&gt;Dynamic&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Expando" rel="tag"&gt;Expando&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET+4.0" rel="tag"&gt;.NET 4.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/C%23+4.0" rel="tag"&gt;C# 4.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DLR" rel="tag"&gt;DLR&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;I have deliberately delayed writing this post to try and get my heads around all the dynamic features in .NET 4.0. At first read, I thought it was just the Expando object and whenever you use the ExpandoObject in your code, the code runs in DLR. Though this is partly true, I realised there is a bit more to the dynamic features than just a two-liner. &lt;/p&gt;  &lt;p align="justify"&gt;The Dynamic Features are implemented in the following forms in .NET 4.0&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;The Expando Object&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;The Dynamic Object&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;The Dynamic Language Runtime (DLR)&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style="font-size:100%;"&gt;ExpandoObject&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As the name roughly suggests, expandos are expandable objects which means you can add properties, methods and even events at runtime. You can also set and get the values of such members.&lt;/p&gt;  &lt;p&gt;The syntax to create expandable objects is as follows&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;dynamic person = new ExpandoObject();  &lt;br /&gt;person.FirstName = "test First Name";   &lt;br /&gt;person.LastName = "test Last Name";&lt;/p&gt;&lt;/blockquote&gt;  &lt;p align="justify"&gt;You will see that I have created the person object as dynamic. We will come to that a bit more later. If you compile a solution, with just this piece of code, it will compile perfectly fine. &lt;/p&gt;  &lt;p align="justify"&gt;You can also pass Expando objects as parameters to other methods or functions. Beware that when you do so, you will not get intellisense on the dynamic object because they aren’t yet resolved; they are resolved only during runtime. Below is a code snippet where I have created an ExpandoObject and passed that as a parameter to another method that displays the values of the object’s. members.&lt;/p&gt;  &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background- padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Dynamic;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum7"  style="color:#606060;"&gt;   7:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum8"  style="color:#606060;"&gt;   8:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; DLRExample&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum9"  style="color:#606060;"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum10"  style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Program&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum11"  style="color:#606060;"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum12"  style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum13"  style="color:#606060;"&gt;  13:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum14"  style="color:#606060;"&gt;  14:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum15"  style="color:#606060;"&gt;  15:&lt;/span&gt;             dynamic Vehicle = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ExpandoObject();&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum16"  style="color:#606060;"&gt;  16:&lt;/span&gt;             Vehicle.Make = &lt;span style="color:#006080;"&gt;"Ford"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum17"  style="color:#606060;"&gt;  17:&lt;/span&gt;             Vehicle.Model = &lt;span style="color:#006080;"&gt;"Endeavour"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum18"  style="color:#606060;"&gt;  18:&lt;/span&gt;             Vehicle.Engine = &lt;span style="color:#006080;"&gt;"4 cylinder"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum19"  style="color:#606060;"&gt;  19:&lt;/span&gt;             Vehicle.Color = &lt;span style="color:#006080;"&gt;"Black"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum20"  style="color:#606060;"&gt;  20:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum21"  style="color:#606060;"&gt;  21:&lt;/span&gt;             WriteVehicleDetails(Vehicle);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum22"  style="color:#606060;"&gt;  22:&lt;/span&gt;             Console.ReadLine();&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum23"  style="color:#606060;"&gt;  23:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum24"  style="color:#606060;"&gt;  24:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum25"  style="color:#606060;"&gt;  25:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum26"  style="color:#606060;"&gt;  26:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; WriteVehicleDetails(dynamic vehicleobject)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum27"  style="color:#606060;"&gt;  27:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum28"  style="color:#606060;"&gt;  28:&lt;/span&gt;             Console.WriteLine(&lt;span style="color:#006080;"&gt;"The make of the vehicle is {0}"&lt;/span&gt;, vehicleobject.Make);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum29"  style="color:#606060;"&gt;  29:&lt;/span&gt;             Console.WriteLine(&lt;span style="color:#006080;"&gt;"The color of the vehicle is {0}"&lt;/span&gt;, vehicleobject.Color);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum30"  style="color:#606060;"&gt;  30:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum31"  style="color:#606060;"&gt;  31:&lt;/span&gt;     }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum32"  style="color:#606060;"&gt;  32:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align="justify"&gt;Similarly, .NET allows you to add methods at runtime to an expando object. In C#, you can add methods by using lambda expressions. The syntax for the same is as below&lt;/p&gt;&lt;p align="justify"&gt;expandObject.Increment = (Action)(() =&amp;gt; { expandoObject.attribute++; });&lt;/p&gt;&lt;p align="justify"&gt;I have modified the above code to add a method to the ExpandoObject called ChangeVehicleColor. The method changes the color of the vehicle to white from its existing value. The new code is as below&lt;/p&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;span class="Apple-style-span" style="line-height: normal;"&gt;&lt;br /&gt;&lt;/span&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt; 2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/span&gt;&lt;br /&gt; &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Dynamic;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum7"  style="color:#606060;"&gt;   7:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum8"  style="color:#606060;"&gt;   8:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; DLRExample&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum9"  style="color:#606060;"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum10"  style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Program&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum11"  style="color:#606060;"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum12"  style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum13"  style="color:#606060;"&gt;  13:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum14"  style="color:#606060;"&gt;  14:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum15"  style="color:#606060;"&gt;  15:&lt;/span&gt;             dynamic Vehicle = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ExpandoObject();&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum16"  style="color:#606060;"&gt;  16:&lt;/span&gt;             Vehicle.Make = &lt;span style="color:#006080;"&gt;"Ford"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum17"  style="color:#606060;"&gt;  17:&lt;/span&gt;             Vehicle.Model = &lt;span style="color:#006080;"&gt;"Endeavour"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum18"  style="color:#606060;"&gt;  18:&lt;/span&gt;             Vehicle.Engine = &lt;span style="color:#006080;"&gt;"4 cylinder"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum19"  style="color:#606060;"&gt;  19:&lt;/span&gt;             Vehicle.Color = &lt;span style="color:#006080;"&gt;"Black"&lt;/span&gt;;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum20"  style="color:#606060;"&gt;  20:&lt;/span&gt;             Vehicle.ChangeVehicleColor = (Action)(() =&amp;gt; {Vehicle.Color=&lt;span style="color:#006080;"&gt;"White"&lt;/span&gt;;});&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum21"  style="color:#606060;"&gt;  21:&lt;/span&gt;             WriteVehicleDetails(Vehicle);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum22"  style="color:#606060;"&gt;  22:&lt;/span&gt;             Vehicle.ChangeVehicleColor();&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum23"  style="color:#606060;"&gt;  23:&lt;/span&gt;             WriteVehicleDetails(Vehicle);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum24"  style="color:#606060;"&gt;  24:&lt;/span&gt;             Console.ReadLine();&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum25"  style="color:#606060;"&gt;  25:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum26"  style="color:#606060;"&gt;  26:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum27"  style="color:#606060;"&gt;  27:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum28"  style="color:#606060;"&gt;  28:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; WriteVehicleDetails(dynamic vehicleobject)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum29"  style="color:#606060;"&gt;  29:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum30"  style="color:#606060;"&gt;  30:&lt;/span&gt;             Console.WriteLine(&lt;span style="color:#006080;"&gt;"The make of the vehicle is {0}"&lt;/span&gt;, vehicleobject.Make);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum31"  style="color:#606060;"&gt;  31:&lt;/span&gt;             Console.WriteLine(&lt;span style="color:#006080;"&gt;"The color of the vehicle is {0}"&lt;/span&gt;, vehicleobject.Color);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum32"  style="color:#606060;"&gt;  32:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum33"  style="color:#606060;"&gt;  33:&lt;/span&gt;     }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum34"  style="color:#606060;"&gt;  34:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Please note that the syntax to invoke the method in C# is slightly different from VB.NET. In VB.NET, you will have to use the Invoke function explicitly to call the dynamic method.&lt;/p&gt;&lt;p align="justify"&gt;Lastly, the expando object also implements the generic IDictionary interface. This enables developers to enumerate the members of the object, if need be. The syntax to enumerate the members is fairly simple. For the vehicle object above, the code will be as below&lt;/p&gt;&lt;blockquote&gt;  &lt;p align="justify"&gt;foreach (var property in (IDictionary&amp;lt;String, Object&amp;gt;)Vehicle)&lt;/p&gt;  &lt;p align="justify"&gt;{&lt;/p&gt;  &lt;p align="justify"&gt;      Console.WriteLine(property.Key + ": " + property.Value);&lt;/p&gt;  &lt;p align="justify"&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:100%;"&gt;Dynamic Object&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p align="justify"&gt;The dynamic object has been introduced in C# for a variety of reasons. One of the most important aspects of the dynamic object is that it skips type checking during compile time. You can invoke any method on the dynamic object type without having to worry about compiling errors.&lt;/p&gt;&lt;p align="justify"&gt;Thought at the outset, the dynamic and expando objects seem similar, there are a number of differences between the two. While you can instantiate an expandoobject class, you cannot do the same with a dynamic class. Dynamic object is just a holding class. They are declared with the &lt;em&gt;dynamic&lt;/em&gt; keyword as shown in my first example in this post.&lt;/p&gt;&lt;p align="justify"&gt;Some of the practical usages of the dynamic object are with COM Interops. Instead of trying to tightly bind an interop class you can always declare that class as dynamic. You will do away with a lot of type casting that needs to be done otherwise.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:100%;"&gt;Dynamic Language Runtime (DLR)&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p align="justify"&gt;The DLR is an open source runtime that sits above the CLR and ensures the working of the dynamic languages in .NET. Apart from the two objects described above, .NET also supports a couple of dynamic languages like IronRuby and IronPython. These run on the DLR. You can download the latest version of DLR from &lt;a href="http://www.codeplex.com/dlr" target="_blank"&gt;codeplex&lt;/a&gt;.&lt;/p&gt;&lt;p align="justify"&gt;What the DLR does is to keep track of usages of the dynamic objects and ensures that they are evaluated at runtime. For this, the DLR has three services&lt;/p&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="justify"&gt;Expression Trees  - These represent language syntaxes and semantics&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="justify"&gt;Call Site Caching – These help track dynamic object usages and information about operations on the Dynamic Objects&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="justify"&gt;Dynamic Object Interoperability – These are essentially a set of interfaces that help creation of dynamic objects.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p align="justify"&gt;You can get more information about the DLR &lt;a href="http://msdn.microsoft.com/en-us/library/dd233052(VS.100).aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:100%;"&gt;Usage Scenarios&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p align="justify"&gt;Now that we have seen the different elements of dynamic features in C# 4.0, let me try and explain where I think these can be used.&lt;/p&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="justify"&gt;The Expando object is interoperable between different framework languages. So it is an obvious choice in situations where you have to pass objects between different framework languages.&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="justify"&gt;String to object conversion scenarios. A scenario commonly found in projects where mainframe is involved. I think it would be compelling to use the Expando object along with text generation templates to come up with a code generator for mapping mainframe strings to application objects&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="justify"&gt;As mentioned earlier in the post, the dynamic object is a good choice for interacting with COM interops. Not only that, I think it is very useful to also be used with scripting objects.&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="justify"&gt;If these two objects don’t do the trick for you, remember you can always create your own dynamic objects by implementing the IDynamicMetaObjectProvider interface.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p align="justify"&gt;That concludes this post regarding the dynamic features in C# 4.0. I hope this has given you a good overview for you to start exploring these objects in a bit more detail&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;strong&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8050162892970302266?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8050162892970302266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/12/net-40-and-vs-2010-series-dynamic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8050162892970302266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8050162892970302266'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/12/net-40-and-vs-2010-series-dynamic.html' title='.NET 4.0 and VS 2010 Series – Dynamic Features'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8908330511624690640</id><published>2009-11-21T08:58:00.000-08:00</published><updated>2009-11-21T09:40:04.038-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>.NET 4.0 and VS 2010 Series – Named and Optional Parameters</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c73ac34c-af21-46fe-bf2e-ced717109c88" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.NET+4.0" rel="tag"&gt;.NET 4.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Named+Parameters" rel="tag"&gt;Named Parameters&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Optional+Parameters" rel="tag"&gt;Optional Parameters&lt;/a&gt;,&lt;a href="http://technorati.com/tags/C%23+4.0" rel="tag"&gt;C# 4.0&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;After my posts on the framework features over the past couple of weeks, I will now start focussing on the language aspects of C# 4.0. In C# 4.0, named and optional parameters have been introduced. This is one feature that I have been waiting for so I am only glad that the .NET team has decided to introduce this feature in C# 4.0.&lt;/p&gt;  &lt;p align="justify"&gt;VB 6.0 programmers are aware of the usage of the optional parameters.  It used to be declared as &lt;/p&gt;  &lt;pre&gt; Sub DoSomething(Optional ByVal Switch As Boolean = False)&lt;/pre&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif; white-space: normal; font-size: 16px; "&gt;What the above declaration meant was that you could call the DoSomething method without explicitly passing the &lt;em&gt;Switch&lt;/em&gt; parameter. The default value of false will be assigned to the variable if it was not passed.&lt;/span&gt;&lt;/pre&gt;&lt;p align="justify"&gt;This was not possible in .NET. The workaround was to declare overloaded methods. You do not need to do that anymore. In C# 4.0, you can declare a method with an optional parameter simply by assigning a default value for the parameter in question like the example below. &lt;/p&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;private string Extract(String inputString, int endIndex=0, int startIndex =0)&lt;/div&gt;&lt;p&gt;   &lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p align="justify"&gt;Named parameters as the name suggests, enable the developers to skip a parameter while calling the method if they wish to. This is done by passing the parameter by quoting its name and value separated by a colon as shown in the syntax below&lt;/p&gt;&lt;blockquote&gt;&lt;p align="justify"&gt;Extract(inputString, startIndex: 4);&lt;/p&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;p align="justify"&gt;The syntax above calls the method extract with three parameters the signature of which is described previously. You will notice that the second parameter endIndex has been skipped and the value is being passed for startIndex. Below is the complete code snippet&lt;/p&gt;&lt;br /&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Diagnostics.Contracts;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; NamedOptionalParams&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Program&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;         {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;             String inputString = &lt;span style="color:#006080;"&gt;"ABCDEFGHIJKLMNOPQRSTUVWXYZ"&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;             String result = Extract(inputString,6);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;             String result1 = Extract(inputString, startIndex: 4);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;             String result2 = Extract(inputString, startIndex: 6, endIndex: 10);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt;             Console.WriteLine(result);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum19" style="color:#606060;"&gt;  19:&lt;/span&gt;             Console.WriteLine(result1);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum20" style="color:#606060;"&gt;  20:&lt;/span&gt;             Console.WriteLine(result2);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum21" style="color:#606060;"&gt;  21:&lt;/span&gt;             Console.ReadLine();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum22" style="color:#606060;"&gt;  22:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum23" style="color:#606060;"&gt;  23:&lt;/span&gt;         }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum24" style="color:#606060;"&gt;  24:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum25" style="color:#606060;"&gt;  25:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//this method creates a substring based on the input parameters&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum26" style="color:#606060;"&gt;  26:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//1. The input string is always passed&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum27" style="color:#606060;"&gt;  27:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//2. Start Index is an optional parameter. If this is not passed then the &lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum28" style="color:#606060;"&gt;  28:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//   start is assumed to be 0 which is the default value&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum29" style="color:#606060;"&gt;  29:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//3. The End Index can be omitted. If it is omitted, then start Index has to&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum30" style="color:#606060;"&gt;  30:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//   be passed and the string is from the start index to the end of the input&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum31" style="color:#606060;"&gt;  31:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//   string&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum32" style="color:#606060;"&gt;  32:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Extract(String inputString, &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; endIndex=0, &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; startIndex =0)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum33" style="color:#606060;"&gt;  33:&lt;/span&gt;         {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum34" style="color:#606060;"&gt;  34:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum35" style="color:#606060;"&gt;  35:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (endIndex==0)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum36" style="color:#606060;"&gt;  36:&lt;/span&gt;             {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum37" style="color:#606060;"&gt;  37:&lt;/span&gt;                 endIndex = inputString.Length;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum38" style="color:#606060;"&gt;  38:&lt;/span&gt;             }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum39" style="color:#606060;"&gt;  39:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum40" style="color:#606060;"&gt;  40:&lt;/span&gt;             String outString = inputString;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum41" style="color:#606060;"&gt;  41:&lt;/span&gt;             outString = inputString.Substring(startIndex, (endIndex - startIndex));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum42" style="color:#606060;"&gt;  42:&lt;/span&gt;             &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum43" style="color:#606060;"&gt;  43:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; outString;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum44" style="color:#606060;"&gt;  44:&lt;/span&gt;         }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum45" style="color:#606060;"&gt;  45:&lt;/span&gt;     }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum46" style="color:#606060;"&gt;  46:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;p align="justify"&gt;In the above example, the extract method just creates a substring for a specified start and end index. I have made three calls to the method. Note that with Named Parameters, the order in which you pass the parameters is not important as long as you don’t forget to name them correctly. You can see this in Line 17 of the above code.&lt;/p&gt;&lt;p&gt;That is it for this post on named and optional parameters. They are quite a useful feature that will reduce the number of overloaded methods that we will have to write. I am sure you will find more ways of putting them to use. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8908330511624690640?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8908330511624690640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/net-40-and-vs-2010-series-named-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8908330511624690640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8908330511624690640'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/net-40-and-vs-2010-series-named-and.html' title='.NET 4.0 and VS 2010 Series – Named and Optional Parameters'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8861121852421100061</id><published>2009-11-17T18:43:00.001-08:00</published><updated>2009-11-17T18:43:53.614-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>.NET 4.0 and VS 2010 Series - PIA – Rest in Peace</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:21187181-7f9d-45d3-b38a-9c3bf8f48965" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.NET+4.0" rel="tag"&gt;.NET 4.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/PIA" rel="tag"&gt;PIA&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Interop" rel="tag"&gt;Interop&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Embedded+Interop+Types" rel="tag"&gt;Embedded Interop Types&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Type+Equivalence" rel="tag"&gt;Type Equivalence&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;In previous versions of .NET, Primary Interop Assemblies (PIA) acted as the bridge between unmanaged COM components and managed code. Though PIA solved the problem of marshalling for almost all types, they came with their own problems. One of the biggest problem was that even if a small feature was used, the developer had to ship the complete PIA which is not a small payload by any means.&lt;/p&gt;  &lt;p align="justify"&gt;Also, a developer had to develop an assembly for each version of word or excel that the application targeted. This drastically increased the size and the complexity of the deployment package.&lt;/p&gt;  &lt;p align="justify"&gt;With .NET 4.0 this has changed. Developers no longer need to ship the whole PIA. .NET 4.0 gives the developer the flexibility of embedding only those features that are used by the application rather than shipping the whole assembly. This also means that the developer does not need to worry about the availability of the target applications like Word or Excel. Enabling embedded interop assemblies is very easy. You right click the interop reference and change the EmbedInteropTypes from false to True. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_2cIm7h7Xp2w/SwNfXxdSLYI/AAAAAAAAALs/hWP4YH_dTkE/s1600-h/Enbed3.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Enbed" border="0" alt="Enbed" src="http://lh3.ggpht.com/_2cIm7h7Xp2w/SwNfYqpNIzI/AAAAAAAAALw/HRel9nZ2zU8/Enbed_thumb1.jpg?imgmax=800" width="261" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;When you do that, the interop assemblies are no longer referred. You can confirm this by using the reflector. The snapshot will look like below. Note that the Excel and Word are now namespaces within&amp;#160; the project instead of references. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_2cIm7h7Xp2w/SwNfZb9Ld9I/AAAAAAAAAL0/U2UR7S3NJik/s1600-h/Reflector%5B2%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Reflector" border="0" alt="Reflector" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/SwNfaGvOkgI/AAAAAAAAAL4/BBB5RWjB6vk/Reflector_thumb.jpg?imgmax=800" width="210" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8861121852421100061?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8861121852421100061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/net-40-and-vs-2010-series-pia-rest-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8861121852421100061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8861121852421100061'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/net-40-and-vs-2010-series-pia-rest-in.html' title='.NET 4.0 and VS 2010 Series - PIA – Rest in Peace'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_2cIm7h7Xp2w/SwNfYqpNIzI/AAAAAAAAALw/HRel9nZ2zU8/s72-c/Enbed_thumb1.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8141453726054334546</id><published>2009-11-06T23:09:00.001-08:00</published><updated>2009-11-06T23:10:52.407-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VPC'/><category scheme='http://www.blogger.com/atom/ns#' term='VHD'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>How to: Increase the size of your virtual hard disk</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1ea66487-b106-48c3-a6e7-a260d5bf22dd" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VHD" rel="tag"&gt;VHD&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Harddisk" rel="tag"&gt;Harddisk&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VHD+Resizer" rel="tag"&gt;VHD Resizer&lt;/a&gt;,&lt;a href="http://technorati.com/tags/How+to" rel="tag"&gt;How to&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Microsoft+Virtual+PC" rel="tag"&gt;Microsoft Virtual PC&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Virtual+Image" rel="tag"&gt;Virtual Image&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DISKPART" rel="tag"&gt;DISKPART&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;If you have run out of space in your virtual image hard disk and didn’t know the way out of it; read on. I ran into this problem last week and found the following solution after a bit of googling. Though there were a lot of posts targeted at VMWare, I was looking for ones specific to Microsoft VPC. The magic tool that you have to look at is called &lt;a href="http://vmtoolkit.com/files/folders/converters/entry87.aspx" target="_blank"&gt;VHD Resizer.&lt;/a&gt; It is a free download available from the &lt;a href="http://vmtoolkit.com/" target="_blank"&gt;VM tool kit&lt;/a&gt; site. You just have to register on the site to download. &lt;/p&gt;  &lt;p align="justify"&gt;When you run the tool, it will ask you to point to the vhd whose hard disk size you want to increase. You can also set the size you want to increase it to. The only thing that needs to be remembered, is that it makes a copy of the VHD so you will need the disk space to cope with it. &lt;/p&gt;  &lt;p align="justify"&gt;When this process is complete, the next thing you have to do is to make sure your volume uses the new space allocated. You can do this by using the DISKPART command. You will find the necessary instructions &lt;a href="http://support.microsoft.com/kb/325590" target="_blank"&gt;here&lt;/a&gt;. That’s it!!! You will have your new drive with loads of space!!! &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8141453726054334546?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8141453726054334546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/how-to-increase-size-of-your-virtual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8141453726054334546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8141453726054334546'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/how-to-increase-size-of-your-virtual.html' title='How to: Increase the size of your virtual hard disk'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8224766471641044383</id><published>2009-11-03T16:59:00.001-08:00</published><updated>2009-11-03T17:07:34.833-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Code Contracts'/><title type='text'>VS 2010 and .NET 4.0 Series – Code Contracts - II</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:28c595ab-1bf7-46b1-8b1f-b07ec38cf783" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.NET+4.0" rel="tag"&gt;.NET 4.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VS+2010" rel="tag"&gt;VS 2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Code+Contracts" rel="tag"&gt;Code Contracts&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Invariant" rel="tag"&gt;Invariant&lt;/a&gt;,&lt;a href="http://technorati.com/tags/PostConditions" rel="tag"&gt;PostConditions&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;In the &lt;a href="http://vaideeswaranr.blogspot.com/2009/10/visual-studio-2010-and-net-40-series.html" target="_blank"&gt;first&lt;/a&gt; part of this series, I wrote about how you can check preconditions with Code Contracts. We also looked at some of the features of postconditions. In this post, we will implement postconditions with an example and go on to look at object invariants.&lt;/p&gt;  &lt;p align="justify"&gt;You can implement Postconditions using Contract.Ensures method. Similar to the Contract.Requires, this takes in a boolean parameter and can display a string as the error message. Unlike the Requires method, Contract.Ensures cannot throw a specific exception. &lt;/p&gt;  &lt;p&gt;We will use the same Concatenate method that we kicked off in the first part and enhance that with some postconditions checks. Here is what it looks like&lt;/p&gt;  &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Concatenate(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; leadingstring, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; trailingstring)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt;        {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;            &lt;span style="color:#008000;"&gt;//raise an exception if the contract fails&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;            Contract.Requires&amp;lt;ArgumentNullException&amp;gt;(leadingstring.Length &amp;gt; 0);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;            &lt;span style="color:#008000;"&gt;//make sure the string is greater than 10 characters before the code exits the method&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;            Contract.Ensures(Contract.Result&amp;lt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&amp;gt;().Length &amp;gt; 10, &lt;span style="color:#006080;"&gt;"The string is too short"&lt;/span&gt;);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;            &lt;span style="color:#008000;"&gt;//ensure that the concatenated string is at least longer than the leading string by 2&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;            Contract.Ensures(Contract.Result&amp;lt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&amp;gt;().Length &amp;gt; Contract.OldValue&amp;lt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&amp;gt;(leadingstring).Length + 2, &lt;span style="color:#006080;"&gt;"The value of the concatenated string is not long enough"&lt;/span&gt;);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;            leadingstring = String.Concat(leadingstring, trailingstring)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; leadingstring;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;        }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;The method now returns the concatenated string. It also includes a couple of ensures statements. Note that though we are implementing postconditions, the Contract.Ensures statement should be included at the beginning of the method and not at the end. There are two checks I have done&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt;&lt;div align="justify"&gt;The first to make sure that the length of the concatenated string is greater than 10. The Contract.Result returns the value that is being returned from the method.&lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;li&gt;&lt;div align="justify"&gt;The second check makes sure that the concatenated string is at least 2 characters longer than the leading string.  Here, I have used the Contract.OldValue to get the original value of leadingstring when it entered the method.&lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p align="justify"&gt;Unlike Contract.Requires, you will not be able to catch a specific exception if the Contract.Ensures fails. In the main method, I have caught a generic exception to handle any contract exceptions. Below is my main method with the changes.&lt;/p&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;span class="Apple-style-span" style="line-height: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;  &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;br /&gt;   &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt;         {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;             {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;                 &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; resultString = Concatenate(&lt;span style="color:#006080;"&gt;"1234567891011"&lt;/span&gt;, &lt;span style="color:#006080;"&gt;"a"&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;                 Console.WriteLine(&lt;span style="color:#006080;"&gt;"The result is {0}"&lt;/span&gt;, resultString);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;                 Console.WriteLine(resultString);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;             }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//catch the argument null exception raised by the contract&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (ArgumentNullException nullString)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;             {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;                 Console.WriteLine(nullString.Message);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;             }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;             {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;                 Console.WriteLine(ex.Message);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt;             }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum19" style="color:#606060;"&gt;  19:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum20" style="color:#606060;"&gt;  20:&lt;/span&gt;             Console.ReadLine();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum21" style="color:#606060;"&gt;  21:&lt;/span&gt;         }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;Object Invariants&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Invariants are code contract features that enable you to check object state and ensure conditions are met when you call methods on these objects. To validate a class using invariants, you will have to write an Invariant method that returns void. This method needs to be decorated with the [ContractInvariantMethod] attribute. &lt;/p&gt;&lt;p align="justify"&gt;To demonstrate the use of invariants, I have refactored the above concatenation code using an external class called StringManipulation. This class that has two public variables and one Concatenate method. &lt;/p&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;span class="Apple-style-span" style="line-height: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;  &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Diagnostics.Contracts;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; CodeContractsSample&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt; {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;     &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; StringManipulation&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; leadingString = &lt;span style="color:#006080;"&gt;"12345678"&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; trailingString = &lt;span style="color:#006080;"&gt;"87654321"&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;         [ContractInvariantMethod]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; ObjectInvariant()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;         {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt;             Contract.Invariant(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.leadingString.Length&amp;gt;5);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum19" style="color:#606060;"&gt;  19:&lt;/span&gt;             Contract.Invariant(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.trailingString.Length&amp;gt;5);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum20" style="color:#606060;"&gt;  20:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum21" style="color:#606060;"&gt;  21:&lt;/span&gt;         }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum22" style="color:#606060;"&gt;  22:&lt;/span&gt;         &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum23" style="color:#606060;"&gt;  23:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Concatenate()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum24" style="color:#606060;"&gt;  24:&lt;/span&gt;         {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum25" style="color:#606060;"&gt;  25:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; String.Concat(leadingString, trailingString);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum26" style="color:#606060;"&gt;  26:&lt;/span&gt;         }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum27" style="color:#606060;"&gt;  27:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum28" style="color:#606060;"&gt;  28:&lt;/span&gt;     }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum29" style="color:#606060;"&gt;  29:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p align="justify"&gt;As you can see, I have also added the CodeInvariant method to check if both the strings are at least 5 characters in length. This means that I will have to initialize the string to pass that condition. Otherwise the object does not get created.&lt;/p&gt;&lt;p align="justify"&gt;The other consideration you will have to keep in mind when using object invariants are that the invariant checks are only done when a method call is made. In essence, invariants will not work for DTO or DataContracts. The workaround is to use Contract.Requires on the property.&lt;/p&gt;&lt;p align="justify"&gt;&lt;strong&gt;Legacy If..Else Blocks&lt;/strong&gt;&lt;/p&gt;&lt;p align="justify"&gt;While Code Contracts are a new .NET 4.0 feature, there exists a lot of legacy code using If…Else… that does similar validations. If you want the .NET framework to treat them as contracts, you can use the EndContractBlock provided the If…Else… are the first set of statements in a method. when you use EndContractBlock, all the If..Else.. conditions are assumed as preconditions.&lt;/p&gt;&lt;p align="justify"&gt;&lt;strong&gt;Code Contract Usage Considerations&lt;/strong&gt;&lt;/p&gt;&lt;p align="justify"&gt;Code Contracts give dev leads and architects a plethora of options to do validations. But, as with anything else, there are certain decision points that need to be taken care of. &lt;/p&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt;&lt;div align="justify"&gt;Decide very early in the project how you are going to use Code Contracts. Though static checking is very powerful, it also puts a lot of drab in your build process. Make sure you are turning static checking on only when you need it.&lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;You could also do runtime checking only on debug builds. This works very well for TDD projects&lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;Be wary of turning on runtime checking on production builds. Remember, .NET 4.0 is still in its beta. &lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;Code Contracts are very extensive. Make sure you understand all the features offered before picking on the best way to do your validations or checks. &lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;When you are using both preconditions and postconditions in the same method, there is a specific order which is recommended. The order according to the Code Contract documentation is as follows&lt;/div&gt;&lt;ul&gt;&lt;br /&gt;     &lt;li&gt;&lt;div align="justify"&gt;Legacy if…Then…Else blocks&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;     &lt;li&gt;&lt;div align="justify"&gt;Contract.Requires to check public preconditions&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;     &lt;li&gt;&lt;div align="justify"&gt;Contract.Ensures to check public postconditions&lt;/div&gt;&lt;br /&gt;     &lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;Contract.EnsuresOnThrow to check public exceptional conditions&lt;/div&gt;&lt;br /&gt;     &lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;Contract.Ensures to check all private postconditions&lt;/div&gt;&lt;br /&gt;     &lt;/li&gt;&lt;li&gt;Contract.EnsuresOnThrow to check all private postconditions before finishing off with the EndContractBlock &lt;/li&gt;&lt;br /&gt;   &lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;You can use Contracts with pre .NET 4.0 versions by referencing the Microsoft.Contracts library. In .NET 4.0 Code Contracts have been integrated into the mscorlib.dll&lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;One of the recommended ways of using Code Contracts is to have a separate config file for contracts.&lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;li&gt;The contracts build output can be shipped along with your build so that other developers\administrators can make use of it. Make sure you understand the different build options.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;p align="justify"&gt;That concludes my two part post on Code Contracts and their usage. The posts try to give you a peek are by no means exhaustive on the features that Code Contracts offer. For complete understanding, I would recommend you download the manual from DevLabs and give it at least a quick skim through. Happy Coding!!!!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8224766471641044383?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8224766471641044383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/vs-2010-and-net-40-series-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8224766471641044383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8224766471641044383'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/11/vs-2010-and-net-40-series-code.html' title='VS 2010 and .NET 4.0 Series – Code Contracts - II'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-1831315125567820325</id><published>2009-10-28T06:42:00.001-07:00</published><updated>2009-10-28T06:50:52.635-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>Visual Studio 2010 and .NET 4.0 Series – Code Contracts</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bb1cf96e-2c62-4186-92d2-c932705fb28f" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.NET+4.0" rel="tag"&gt;.NET 4.0&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Visual+Studio+2010" rel="tag"&gt;Visual Studio 2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VS+2010" rel="tag"&gt;VS 2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Code+Contracts" rel="tag"&gt;Code Contracts&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;I had written a couple of days ago on my &lt;a href="http://vaideeswaranr.blogspot.com/2009/10/visual-studio-2010-and-net-40-beta-2.html" target="_blank"&gt;blog&lt;/a&gt; about the release of VS2010  and .NET 4 Beta 2. Now that I have had a chance to install and play around a bit, I am hoping to explore some of the new features of .NET 4 and VS 2010 in the next few weeks. I will kick off this week with Code Contracts. &lt;/p&gt;  &lt;p align="justify"&gt;According to MSDN, “Code contracts provide a way to specify preconditions, postconditions, and object invariants in your code”.  To work with code contracts .NET 4 now comes with a new namespace &lt;span style="font-family:Aria;color:#0080ff;"&gt;System.Diagnostics.Contracts&lt;/span&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;As mentioned in the above definition, code contracts can be used to check, pre-conditions, post-conditions and invariants. Pre-conditions are conditions that should be satisfied before a method is invoked; post-conditions are conditions that should be met just before the method finishes execution and invariants validate class state. We will look at Pre-Conditions with an example and a peek into Post Conditions in this post. I will finish this off with another post on Post Conditions example and invariants.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Preconditions&lt;/strong&gt;&lt;/p&gt;  &lt;p align="justify"&gt;The Contract.Requires method can be used to validate preconditions. An example of this will be to validate parameters that are being passed into a method.  To demonstrate this, I will create a new console project and write the code below.&lt;/p&gt;  &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Diagnostics.Contracts;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; CodeContractsSample&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Program&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;             Concatenate(String.Empty, &lt;span style="color:#006080;"&gt;"test"&lt;/span&gt;);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;             Console.ReadLine();&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Concatenate(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; leadingstring, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; trailingstring)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum19" style="color:#606060;"&gt;  19:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum20" style="color:#606060;"&gt;  20:&lt;/span&gt;             Contract.Requires(leadingstring.Length &amp;gt; 0, &lt;span style="color:#006080;"&gt;"Ensure leading string is valid."&lt;/span&gt;);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum21" style="color:#606060;"&gt;  21:&lt;/span&gt;             Console.WriteLine(String.Concat(leadingstring,trailingstring));&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum22" style="color:#606060;"&gt;  22:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum23" style="color:#606060;"&gt;  23:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum24" style="color:#606060;"&gt;  24:&lt;/span&gt;     }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum25" style="color:#606060;"&gt;  25:&lt;/span&gt; }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Let us harp a bit on the Contract.Requires method. The method takes two parameters; the first is a boolean condition that needs to be enforced. The second optional parameter is the message that needs to be displayed if the condition evaluates to false. In the above example, the method makes sure the leading string is not empty.&lt;/p&gt;&lt;p align="justify"&gt;When I wrote this code and ran it, I found it to my surprise that the contracts were not working. After a bit of research, I found that for contracts to work, you need an additional download. You can find the download at &lt;a href="http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx" target="_blank"&gt;Dev Labs&lt;/a&gt;. Once you download and run the installer, you will find an additional tab called Contracts in your solution properties as shown below.&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_2cIm7h7Xp2w/SuhKOoNZBSI/AAAAAAAAALY/XnGB9L5d7p8/s1600-h/CodeContracts6.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="CodeContracts" border="0" alt="CodeContracts" src="http://lh6.ggpht.com/_2cIm7h7Xp2w/SuhKPpqTl7I/AAAAAAAAALc/vK6gMLBY5lg/CodeContracts_thumb4.jpg?imgmax=800" width="618" height="473" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p align="justify"&gt;You can then control how your contracts work in this window. Please note that to without Team System you can do only runtime checking.  Running the application now throws the designated message if we pass an empty string to the Concatenate method.&lt;/p&gt;&lt;p align="justify"&gt;A variant of this is the Requires&amp;lt;&amp;gt; method which takes a generic TException parameter. Below is the code to raise an exception and catch it in code. One thing you have to make sure is you turn off the assert on contract failure setting in the Code Contracts settings tab. This will ensure exceptions are raised from the contracts.&lt;/p&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;br /&gt; &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;br /&gt;   &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Diagnostics.Contracts;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; CodeContractsSample&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Program&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;             {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;                 Concatenate(String.Empty, &lt;span style="color:#006080;"&gt;"test"&lt;/span&gt;);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;                 &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt;             }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum19" style="color:#606060;"&gt;  19:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//catch the argument null exception raised by the contract&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum20" style="color:#606060;"&gt;  20:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt;(ArgumentNullException nullString)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum21" style="color:#606060;"&gt;  21:&lt;/span&gt;             {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum22" style="color:#606060;"&gt;  22:&lt;/span&gt;                 Console.WriteLine(nullString.Message);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum23" style="color:#606060;"&gt;  23:&lt;/span&gt;             }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum24" style="color:#606060;"&gt;  24:&lt;/span&gt;             Console.ReadLine();&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum25" style="color:#606060;"&gt;  25:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum26" style="color:#606060;"&gt;  26:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum27" style="color:#606060;"&gt;  27:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Concatenate(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; leadingstring, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; trailingstring)&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum28" style="color:#606060;"&gt;  28:&lt;/span&gt;         {&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum29" style="color:#606060;"&gt;  29:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum30" style="color:#606060;"&gt;  30:&lt;/span&gt;             &lt;span style="color:#008000;"&gt;//raise an exception if the contract fails&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum31" style="color:#606060;"&gt;  31:&lt;/span&gt;             Contract.Requires&amp;lt;ArgumentNullException&amp;gt;(leadingstring.Length &amp;gt; 0);&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum32" style="color:#606060;"&gt;  32:&lt;/span&gt;             Console.WriteLine(String.Concat(leadingstring, trailingstring));&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum33" style="color:#606060;"&gt;  33:&lt;/span&gt;  &lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum34" style="color:#606060;"&gt;  34:&lt;/span&gt;         }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum35" style="color:#606060;"&gt;  35:&lt;/span&gt;     }&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum36" style="color:#606060;"&gt;  36:&lt;/span&gt; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;PostConditions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Though most of the basic concepts are the same for post and preconditions, postconditions offer a bit more flexibility and features that preconditions do not. Postconditions are validated by using the Contract.Ensures method. Postconditions also offer the following capabilities&lt;/p&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt;&lt;div align="justify"&gt;Ability to refer the return value of a method using Contract.Result&amp;lt;T&amp;gt; where T should be of the same type as the return type of the method. Obviously you cannot use Result for methods that do not return anything.&lt;/div&gt;&lt;/li&gt;&lt;br /&gt; &lt;li&gt;&lt;div align="justify"&gt;Ability to check the value of a variable at the beginning of the method. This can be done by using Contract.OldValue&amp;lt;T&amp;gt;(e) where e is the variable for which you want the old value and T is the type of that variable.&lt;/div&gt;&lt;/li&gt;&lt;br /&gt; &lt;li&gt;&lt;div align="justify"&gt;Ability to ensure a condition is met when an error is thrown in the method. You can use the Contract.EnsuresonThrow&amp;lt;&amp;gt;. &lt;/div&gt;&lt;br /&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p align="justify"&gt;That is it for this post.  I will show you in my next post how to write PostConditions and we will also look at  invariants. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-1831315125567820325?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/1831315125567820325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/visual-studio-2010-and-net-40-series.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/1831315125567820325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/1831315125567820325'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/visual-studio-2010-and-net-40-series.html' title='Visual Studio 2010 and .NET 4.0 Series – Code Contracts'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2cIm7h7Xp2w/SuhKPpqTl7I/AAAAAAAAALc/vK6gMLBY5lg/s72-c/CodeContracts_thumb4.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-9031583897939090480</id><published>2009-10-19T11:14:00.001-07:00</published><updated>2009-10-19T11:14:31.945-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Software'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Visual Studio 2010 and .NET 4.0 Beta 2 now available</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:62f2b4f3-140b-433a-b82f-a13f57eaeaa9" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VS2010" rel="tag"&gt;VS2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET+4" rel="tag"&gt;.NET 4&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Beta" rel="tag"&gt;Beta&lt;/a&gt;,&lt;a href="http://technorati.com/tags/MSDN" rel="tag"&gt;MSDN&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;p align="justify"&gt;Microsoft made available today the beta 2 of VS2010 and .NET 4.0. It is available for MSDN Subscribers on the 19th and its general availability is from the 21st of October. You can download the beta 2 from &lt;a title="https://msdn.microsoft.com/en-us/subscriptions/securedownloads/default.aspx?pv=18%3a370" href="https://msdn.microsoft.com/en-us/subscriptions/securedownloads/default.aspx?pv=18%3a370"&gt;https://msdn.microsoft.com/en-us/subscriptions/securedownloads/default.aspx?pv=18%3a370&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p align="justify"&gt;Apart from bug fixes the Beta 2 also is supposed to have templates for Sharepoint solutions and Azure. More details on Somasegar’s blog &lt;a title="http://blogs.msdn.com/somasegar/" href="http://blogs.msdn.com/somasegar/"&gt;http://blogs.msdn.com/somasegar/&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;I will write more on VS 2010 when I have had a chance to play with it. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-9031583897939090480?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/9031583897939090480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/visual-studio-2010-and-net-40-beta-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/9031583897939090480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/9031583897939090480'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/visual-studio-2010-and-net-40-beta-2.html' title='Visual Studio 2010 and .NET 4.0 Beta 2 now available'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-5155272720838370341</id><published>2009-10-04T10:39:00.001-07:00</published><updated>2009-10-04T10:46:40.511-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>Using Table Value Parameters in SQL Server 2008</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:483942fc-7141-49d4-87c9-e05d61637b82" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Table+Value+Parameters" rel="tag"&gt;Table Value Parameters&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;Table-valued parameter is another exciting new feature in SQL Server 2008. Essentially, TVP solves the problem of inserting multiple rows into the database. Various solutions have been implemented to achieve this, ranging from round trips for every row to comma separated values. With TVP, you can insert multiple rows with a single round trip to the server without having the additional overheads of composition and de-composition of values.&lt;/p&gt;  &lt;p align="justify"&gt;TVP is not entirely new to SQL Server. SQL Server 2000 introduced the table variables which can be used to store a set of records. Where TVP builds on it, is the ability to pass them as input parameters to stored procedures or functions. This could not be done with table variables. &lt;/p&gt;  &lt;p align="justify"&gt;Let us look at some of the features of TVP before we see how they can be used to insert data. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;TVPs can participate in Set based operations.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;They are strongly typed&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;You cannot perform DML operations on TVPs. They can be passed as only READ-ONLY parameters to stored procedures\functions&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Remember that TVPs are materialized in the TempDB. Essentially, it means that if you insert more rows into your TVP, the size of TempDB is what gets affected.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Having seen what TVP is, let us now move onto build an example which will actually use TVP. Here, I will show you a very common scenario that we use for multiple entries. We have an order and each order is comprised of multiple products. I have created the necessary tables using the scripts below&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; Create table dbo.Products&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; (&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; ProductId &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; IDENTITY(1,1) PRIMARY KEY,&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; ProductName varchar(250),&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; ItemRate &lt;span style="color: #0000ff"&gt;decimal&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; )&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt; Create table dbo.Orders&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt; (&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     OrderId &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; IDENTITY(1,1) Primary key,&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     OrderDate datetime,&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     OrderStatus &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt; )&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt; Create Table dbo.OrderDetails&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt; (&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;     OrderId &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; Foreign Key references Orders(OrderId),&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;     ProductId &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; Foreign Key references Products(ProductId),&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;     Quantity &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;,&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;     Amount &lt;span style="color: #0000ff"&gt;decimal&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt; )&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I have also inserted data for the tables above. The next thing to do is to create a user defined type that will insert data into the OrderDetails table. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; Create type dbo.OrderParam &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; Table&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; (ProductId &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;, Quantity &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;, Amount &lt;span style="color: #0000ff"&gt;decimal&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now that the type has been created, let me go ahead and create a stored procedure that takes the just created type as an input parameter. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; Create proc dbo.InsertOrders&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; @OrderItems OrderParam ReadOnly&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;as&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; begin&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     Declare @iOrderId &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     Insert into Orders values (GETDATE(),0)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     Select @iOrderId=SCOPE_IDENTITY()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     Insert into OrderDetails(OrderId, ProductId, Quantity, Amount)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         Select @iOrderId, ProductId, Quantity, Amount from @OrderItems&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt; end&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Notice the fact that the TVPs have been declared read only. Also pay attention to the second insert statement. The values are inserted from the input parameter using a single select statement. The only remaining thing to do is to call this stored procedure from the front end. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;For this purpose, I have created a data grid where users select the orders and save it into the database. Below is the code that goes into the Save Click routine.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SaveButton_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;         {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//create a new datatable to hold the grid data&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;             DataTable OrderParam = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataTable();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//the columns are the same as the TVP type&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;             OrderParam.Columns.Add(&lt;span style="color: #006080"&gt;&amp;quot;ProductId&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;             OrderParam.Columns.Add(&lt;span style="color: #006080"&gt;&amp;quot;Quantity&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;             OrderParam.Columns.Add(&lt;span style="color: #006080"&gt;&amp;quot;Amount&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;decimal&lt;/span&gt;));&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//loop through the grid to load data into the datatable&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (DataGridViewRow item &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; grdOrders.Rows)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;             {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;                 DataGridViewComboBoxCell prodCell = (DataGridViewComboBoxCell) item.Cells[0];&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (prodCell.Value != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;                 {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;                     DataRow prdRow = OrderParam.NewRow();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;                     prdRow[0] = prodCell.Value;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;                     prdRow[1] = item.Cells[1].Value;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;                     prdRow[2] = item.Cells[2].Value;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;                     OrderParam.Rows.Add(prdRow);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;                 }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;             }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//connect to the database to insert the values.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;             var connString = ConfigurationManager.ConnectionStrings[&lt;span style="color: #006080"&gt;&amp;quot;DatabaseConn&amp;quot;&lt;/span&gt;].ConnectionString;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;             SqlConnection dbConn = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlConnection(connString);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;             dbConn.Open();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;using&lt;/span&gt;(SqlCommand cmd = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlCommand(&lt;span style="color: #006080"&gt;&amp;quot;InsertOrders&amp;quot;&lt;/span&gt;, dbConn))&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;             {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;               cmd.CommandType = CommandType.StoredProcedure;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;               cmd.Parameters.AddWithValue(&lt;span style="color: #006080"&gt;&amp;quot;OrderItems&amp;quot;&lt;/span&gt;, OrderParam);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;               cmd.ExecuteNonQuery();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;             }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;             dbConn.Close();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;         }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;The only thing worth noticing is that I have used a datatable which is quite logical because TVPs are tables anyways. As you can see, the savings in the number of round trips to the database is enormous. The USP of the TVPs lie in the fact that they are not hard to implement at all.&amp;#160; Have fun!!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-5155272720838370341?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/5155272720838370341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/using-table-value-parameters-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/5155272720838370341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/5155272720838370341'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/using-table-value-parameters-in-sql.html' title='Using Table Value Parameters in SQL Server 2008'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-3457800389497565538</id><published>2009-10-02T22:04:00.001-07:00</published><updated>2009-10-02T22:04:23.521-07:00</updated><title type='text'>Time well SpEnt</title><content type='html'>&lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:971d5af2-4bd9-43ba-a398-443783b2337c" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Quizzing" rel="tag"&gt;Quizzing&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ASAP" rel="tag"&gt;ASAP&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Chennai" rel="tag"&gt;Chennai&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p align="justify"&gt;When a relatively unheard of theatre group comes forward to do a quiz, you are not sure what to expect. But ASAP did themselves only favours, be it the quiz or the short sketch they showcased just before the finals. The only disappointing thing for the evening was the number of teams participating. The quiz master put the number at 100 which seemed a bit low given that Chennai usually attracts a lot of participation. &lt;/p&gt;  &lt;p align="justify"&gt;The quiz kicked off with 40 question prelims which seems to be the standard nowadays. It fittingly started with a question on the Bapu. &lt;/p&gt;  &lt;p align="justify"&gt;There were questions on Anjali Tendulkar, the Olympics and Quick Gun Murugan. The toughest one seemed to be on the longest winning streak in sports history. I don’t think any of the 100 odd teams got this right. 8 teams qualified for the finals at the end of a low scoring prelims with&amp;#160; “When I was in London” comprising of Srinivasan and Rajagopal coming out tops. &lt;/p&gt;  &lt;p align="justify"&gt;The questions in the finals were engrossing bringing out some brilliant answers from the teams. The quality of quizzing was again top-class. JK and Sriram were quick off the blocks but the team of V.V. Ramanan and Ramkumar eventually caught up leading the quiz into the last round. It came down to the last question to decide the winners and “When I was in London” bagged it with a brilliant answer on the word “FAIL”. &lt;/p&gt;  &lt;p align="justify"&gt;Overall a very enjoyable evening. If anything, the finals just seemed to be one round too long but I dont think the ardent quizzers of Chennai would complain given the good quizzing that was in offing. Mention should also go to the quiz master Vinod and his colleague Ganesh for the research and the quality of questions.&lt;/p&gt;  &lt;p align="justify"&gt;I hope that this now goes on to become an annual event and one more annual quiz gets added to the Chennai quizzing calendar. Way to go ASAP!!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-3457800389497565538?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/3457800389497565538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/time-well-spent.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/3457800389497565538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/3457800389497565538'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/10/time-well-spent.html' title='Time well SpEnt'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-4246314647688854111</id><published>2009-09-12T13:01:00.001-07:00</published><updated>2009-09-12T13:01:51.302-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>CLR Integration Changes in SQL Server 2008</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:cd441ca7-76cd-4e7d-a9c2-2f91d50fede9" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CLR+Integration" rel="tag"&gt;CLR Integration&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Nullable+Types" rel="tag"&gt;Nullable Types&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Database" rel="tag"&gt;Database&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;CLR Integration was first introduced in SQL Server 2005. Though there was a lot of excitement when the feature was&amp;#160; introduced, it has since fizzled off. Personally, I think CLR Integration is one of the most underused features of SQL Server. For some reason, we have not been able to move away from extended procedures or UDFs to writing CLR Integrated code.&lt;/p&gt;  &lt;p align="justify"&gt;In SQL Server 2008, there are two noticeable introductions to CLR Introduction. One is the support for LINQ and the other is the support for Nullable types. &lt;/p&gt;  &lt;p align="justify"&gt;To enable CLR support in SQL Server, you first have to switch it on. This is done by running the sp_configure with clr enabled = 1.&amp;#160; One thing to keep in mind is when you are using nullable types, you cannot use the automatic deployment option within Visual Studio 2008. You will have to register your assemblies manually. I will briefly show you how it is done.&lt;/p&gt;  &lt;p align="justify"&gt;Once you have turned the support for CLR on, the next step is to create your assembly. For this, I have a stored procedure written in Visual Studio. The code for the same is as below&lt;/p&gt;  &lt;p align="justify"&gt;&amp;#160;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.SqlClient;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.SqlTypes;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; Microsoft.SqlServer.Server;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; StoredProcedures&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     [Microsoft.SqlServer.Server.SqlProcedure]&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SearchEmployee(Int64? iEmployeeId, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; Int32? iVacationhours)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;         iVacationhours = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (iEmployeeId !=&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//open the sql connection with the current context&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (SqlConnection connection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlConnection(&lt;span style="color: #006080"&gt;&amp;quot;context connection=true&amp;quot;&lt;/span&gt;))&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;             {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;                 &lt;span style="color: #008000"&gt;//open the connection&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;                 connection.Open();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;                 &lt;span style="color: #008000"&gt;//build the query and execute it               &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; query = &lt;span style="color: #006080"&gt;&amp;quot;Select VacationHours from HumanResources.Employee where EmployeeId = &amp;quot;&lt;/span&gt; + iEmployeeId.ToString();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;                 SqlCommand sCommand = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlCommand(query, connection);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;                 SqlDataReader vacationReader = sCommand.ExecuteReader();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (vacationReader)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;                 {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;                     vacationReader.Read();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;                     iVacationhours = vacationReader.GetInt32(0);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;                 }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;             }            &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;         }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;         &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;     }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt; };&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;The code just returns the vacation hours for a given employee. The point worth noting is that both input and output parameters are nullable types. The next step is to add the assembly to the SQL Server database. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The syntax to do that is &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span class="lnum"&gt;&amp;#160;&amp;#160; 1: &lt;/span&gt;create assembly NullableTypes from &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="str"&gt;'C:\Users\Administrator\Documents\Visual Studio 2008\Projects\NullableTypesExample\NullableTypesExample\bin\Debug\NullableTypesExample.dll'&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;Go&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Once the assembly is registered, you can now proceed to create your stored procedure pointing it to the managed code by executing the statement below&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;Create Proc dbo.SearchEmployee(@a bigint, @b smallint output)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;as&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;EXTERNAL NAME NullableTypes.[StoredProcedures].SearchEmployee&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;GO&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;That is it!!! You are now all set to execute the stored procedure and check the results. For your reference, I am also giving below the statements to execute the procedure&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;declare @outvalue smallint&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;set @outvalue = 0&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;exec dbo.SearchEmployee 1,@outvalue output&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;select @outvalue&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If I change the input value to null, null will be returned as output exhibiting support for Nullable Types.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-4246314647688854111?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/4246314647688854111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/09/clr-integration-changes-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/4246314647688854111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/4246314647688854111'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/09/clr-integration-changes-in-sql-server.html' title='CLR Integration Changes in SQL Server 2008'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-4820832112797548321</id><published>2009-08-29T08:26:00.001-07:00</published><updated>2009-08-29T08:26:57.020-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>A Date with SQL Server 2008</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:cbca557d-f684-4f07-ba01-ad6c63476646" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Database" rel="tag"&gt;Database&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Datetime" rel="tag"&gt;Datetime&lt;/a&gt;,&lt;a href="http://technorati.com/tags/datetime2" rel="tag"&gt;datetime2&lt;/a&gt;,&lt;a href="http://technorati.com/tags/datetimeoffset" rel="tag"&gt;datetimeoffset&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SwitchOffset" rel="tag"&gt;SwitchOffset&lt;/a&gt;,&lt;a href="http://technorati.com/tags/datatypes" rel="tag"&gt;datatypes&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;Almost everybody who has worked a fair bit in SQL Server knows that the datetime data type in SQL Server is one of the most primitive. Infact, in a lot of applications I have seen, they don’t even see it worthy of being used, opting to use varchar instead. Their argument: If I am going to convert it into varchar anyways, then I might as well store it in the same format. &lt;/p&gt;  &lt;p align="justify"&gt;Hopefully, that will change with SQL Server 2008. DateTime datatype has been given special attention in the latest edition of SQL Server; so much so that I will stick my neck out and say that it is the only data type that has been enhanced!!! (FILESTREAM is not a data type, remember?). This post is an attempt to give you a preview of what the enhancements are in the DateTime datatypes.&lt;/p&gt;  &lt;p align="justify"&gt;In the previous versions of SQL Server, there were no separate datatypes for date and time. That has changed now. In SQL Server 2008, you have date and time datatypes that let you store only date or time. Apart from this, there is also the datetime2 and datetimeoffset. The datetime2 lets you store a wider range of dates. If you use datetime your minimum value for the year is 1/1/1753. The datetime2 datatype lets you store a wider range and is based on the ANSI standard. The datetimeoffset as you would have already guessed, helps you store dates for different regions. Some of the key points that you have to remember when using the above datatypes are&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;You cannot use mathematical functions or expressions with the new datetime2 datatype. Use DateAdd instead.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Try avoiding the format ‘dmy’. This is the only string format that produces different results with the old datetime and the new datetime2 format. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Most of the old t-sql functions work consistently with both the datetime and the datetime2 datatypes.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;If you are using datetime2, use the SYSDATETIME function for more precision. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Though you can use the Datetimeoffset datatype, SQL Server 2008 does not support automatic support for daylight savings.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;It does not also provide support for timezones, so the most effective way to use the offset is to store the timezone at which the date was entered.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Use the SWITCHOFFSET function of SQL Server to convert the offsets to the timezones.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-4820832112797548321?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/4820832112797548321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/date-with-sql-server-2008.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/4820832112797548321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/4820832112797548321'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/date-with-sql-server-2008.html' title='A Date with SQL Server 2008'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-1534968187944259915</id><published>2009-08-23T07:07:00.001-07:00</published><updated>2009-08-23T07:07:59.886-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quizzing'/><category scheme='http://www.blogger.com/atom/ns#' term='Chennai'/><category scheme='http://www.blogger.com/atom/ns#' term='Indian Quizzing League'/><title type='text'>Madras Quiz 2009</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1f7fe6d0-26d7-42f3-a6a4-fa5bfdbd0b13" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Chennai" rel="tag"&gt;Chennai&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Quizzing" rel="tag"&gt;Quizzing&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Madras+Week" rel="tag"&gt;Madras Week&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Indian+Quizzing+League" rel="tag"&gt;Indian Quizzing League&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;I am just back from the annual Madras quiz that is conducted as a part of the Madras Week celebrations. The quiz this time was conducted by the Indian Quizzing League.&amp;#160; The quiz master for the day was Sylvian Patrick.&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;The event started off with a 30 question prelims. T&lt;/font&gt;&lt;font size="3"&gt;here were some thought-provoking questions from various aspects of Chennai, ranging from the Chennai Metro to the Ergo. On the whole, the prelims were not too tough. A lot of the questions were guessable. Couple of questions from the top of my head&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;What did Gandhiji establish in Chennai in 1918 recognising the importance of the whole nation speaking one language?&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;Who is the most famous grandson of Rajagopala Bhagavadar who excelled in Hari Katha kathakalakshebam?&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;Six teams made it to the finals, which comprised of 5 rounds of Madras Intensive questions. Jayakanthan and his teammate managed to surge ahead wresting the rolling trophy from V.V. Ramanan and Ramshankar who were lacklustre today. There were some quality answers from all the teams. I don’t remember the name of the team who finished second. &lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;Overall the quality of the questions in the finals was passable. I personally believe the Indian Quizzing League need to find themselves some quizmasters. I attended their India quiz and there again, the quizmasters were found wanting.&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-1534968187944259915?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/1534968187944259915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/madras-quiz-2009.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/1534968187944259915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/1534968187944259915'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/madras-quiz-2009.html' title='Madras Quiz 2009'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-8450297254966279263</id><published>2009-08-22T03:08:00.001-07:00</published><updated>2009-08-22T03:19:32.243-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>SQL Server 2008 FILESTREAM – Part – II</title><content type='html'>&lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9596b4b4-f18f-45ee-9839-845e458cee89" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FILESTREAM" rel="tag"&gt;FILESTREAM&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Database" rel="tag"&gt;Database&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Having done the necessary set up for configuring FILESTREAM on a SQL Server instance in &lt;a href="http://vaideeswaranr.blogspot.com/2009/08/sql-server-2008-filestream-part-i.html" target="_blank"&gt;Part - I&lt;/a&gt;, we will now look at how to query a FILESTREAM column from .NET code and insert new files. &lt;/p&gt;  &lt;p align="justify"&gt;For this purpose, I have created one more table called UserMaster. This has the usual details of a user like the first name, last name and a column PhotoId which is a foreignkey to the ProductPhotoId that we created in the previous part.&lt;/p&gt;  &lt;p align="justify"&gt;Querying files or data from the FILESTREAM is not too different from how you would query and display data from an ordinary table. I first create a stored procedure to get the user details and the photo associated with each user. The stored procedure is as below&lt;/p&gt;  &lt;p align="justify"&gt;create proc dbo.GetUserDetails &lt;br /&gt;as &lt;br /&gt;begin &lt;br /&gt;Select    UM.UserId,    UM.UserName,    UM.FirstName,    UM.LastName,    UM.EmailAddress,    PP.ProductPhotoId,    PP.LargePhoto &lt;br /&gt;from &lt;br /&gt;  UserMaster UM    INNER JOIN    ProductPhotoWithFileStream PP &lt;br /&gt;  On  &lt;br /&gt;   PP.ProductPhotoId=UM.PhotoId &lt;br /&gt;end &lt;/p&gt;  &lt;p align="justify"&gt;As you can see, there is nothing special with the above stored procedure. The next step is to display these photos in a Windows form. I have a DataGridView which is going to display the pics. The code for Form.cs is &lt;/p&gt;  &lt;p align="justify"&gt;  &lt;/p&gt;  &lt;div align="justify"&gt;   &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;     &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;       &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; var connString = ConfigurationManager.ConnectionStrings[&lt;span style="color:#006080;"&gt;"FileStreamConn"&lt;/span&gt;].ConnectionString;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; var query = &lt;span style="color:#006080;"&gt;"GetUserDetails"&lt;/span&gt;;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt; var daProducts = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SqlDataAdapter(query,connString);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt; productsGridView.DataSource = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt; productsGridView.Refresh();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt; var binding = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; BindingSource()&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt; productsGridView.DataSource = binding;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt; &lt;span style="color:#008000;"&gt;// Populate a new data table and bind it to the BindingSource.&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt; var table = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; DataTable();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt; daProducts.Fill(table);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt; binding.DataSource = table;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt; &lt;span style="color:#008000;"&gt;// Resize the DataGridView columns to fit the newly loaded content.&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt; productsGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt; productsGridView.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;    Again, nothing fancy. Plain old-fashioned code. But good enough to query the files in the database and display it as shown below.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_2cIm7h7Xp2w/So_DjUQLWTI/AAAAAAAAAHQ/UnVdjU22VvY/s1600-h/ImageDisplay4.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ImageDisplay" border="0" alt="ImageDisplay" src="http://lh4.ggpht.com/_2cIm7h7Xp2w/So_Dken3unI/AAAAAAAAAHU/LCr4giyvx_s/ImageDisplay_thumb2.jpg?imgmax=800" width="377" height="246" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;To insert a user, I create a form where the user will enter the details and select the picture associated with the user. &lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_2cIm7h7Xp2w/So_DkwAPgOI/AAAAAAAAAHY/Zbea7zcPhi4/s1600-h/InsertForm2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="InsertForm" border="0" alt="InsertForm" src="http://lh5.ggpht.com/_2cIm7h7Xp2w/So_Dl0DiOGI/AAAAAAAAAHc/coZl5vyp6io/InsertForm_thumb.jpg?imgmax=800" width="244" height="159" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p align="justify"&gt;We will ignore the rest of the code in the form and concentrate on the Insert Button click. Below is the code for the complete button click event&lt;/p&gt;&lt;div align="justify"&gt;&lt;div face="'Courier New', courier, monospace" size="8pt" color="#f4f4f4" style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;span class="Apple-style-span" style="line-height: normal;"&gt;&lt;br /&gt;&lt;/span&gt;    &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;br /&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum1" style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//1. Call the procedure to insert an empty value as photo and get transaction context&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum2" style="color:#606060;"&gt;   2:&lt;/span&gt; var connString = ConfigurationManager.ConnectionStrings[&lt;span style="color:#006080;"&gt;"FileStreamConn"&lt;/span&gt;].ConnectionString;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum3" style="color:#606060;"&gt;   3:&lt;/span&gt; var query = &lt;span style="color:#006080;"&gt;"GetUserDetails"&lt;/span&gt;;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum4" style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; filePath = String.Empty;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum5" style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; selPhotoPath = txtFilePath.Text;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum6" style="color:#606060;"&gt;   6:&lt;/span&gt; SqlCommand daInsertCommand=&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum7" style="color:#606060;"&gt;   7:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum8" style="color:#606060;"&gt;   8:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum9" style="color:#606060;"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum10" style="color:#606060;"&gt;  10:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum11" style="color:#606060;"&gt;  11:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//1.1open a new connection&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum12" style="color:#606060;"&gt;  12:&lt;/span&gt;     SqlConnection conn = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SqlConnection(connString);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum13" style="color:#606060;"&gt;  13:&lt;/span&gt;     conn.Open();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum14" style="color:#606060;"&gt;  14:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum15" style="color:#606060;"&gt;  15:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum16" style="color:#606060;"&gt;  16:&lt;/span&gt;     SqlTransaction tranPhoto = conn.BeginTransaction(&lt;span style="color:#006080;"&gt;"photoInsert"&lt;/span&gt;);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum17" style="color:#606060;"&gt;  17:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum18" style="color:#606060;"&gt;  18:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//1.2 Execute the command to insert the photo and get the photo id&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum19" style="color:#606060;"&gt;  19:&lt;/span&gt;     daInsertCommand = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SqlCommand(query,conn);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum20" style="color:#606060;"&gt;  20:&lt;/span&gt;     daInsertCommand.Transaction = tranPhoto;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum21" style="color:#606060;"&gt;  21:&lt;/span&gt;     var PhotoId = daInsertCommand.ExecuteScalar();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum22" style="color:#606060;"&gt;  22:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum23" style="color:#606060;"&gt;  23:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//1.3 Get the Path Name for the newly created file.&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum24" style="color:#606060;"&gt;  24:&lt;/span&gt;     query = &lt;span style="color:#006080;"&gt;"Select LargePhoto.PathName() from ProductPhotoWithFilestream where ProductPhotoId = "&lt;/span&gt; + PhotoId;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum25" style="color:#606060;"&gt;  25:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum26" style="color:#606060;"&gt;  26:&lt;/span&gt;     daInsertCommand.CommandText = query;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum27" style="color:#606060;"&gt;  27:&lt;/span&gt;     var PhotoPath = daInsertCommand.ExecuteScalar();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum28" style="color:#606060;"&gt;  28:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!PhotoPath.Equals(DBNull.Value))&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum29" style="color:#606060;"&gt;  29:&lt;/span&gt;     {&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum30" style="color:#606060;"&gt;  30:&lt;/span&gt;         filePath = (&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;)PhotoPath;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum31" style="color:#606060;"&gt;  31:&lt;/span&gt;     }&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum32" style="color:#606060;"&gt;  32:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum33" style="color:#606060;"&gt;  33:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;//1.4 Get the transaction context for writing to the file.&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum34" style="color:#606060;"&gt;  34:&lt;/span&gt;     daInsertCommand.CommandText = &lt;span style="color:#006080;"&gt;"SELECT GET_FILESTREAM_TRANSACTION_CONTEXT()"&lt;/span&gt;;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum35" style="color:#606060;"&gt;  35:&lt;/span&gt;     var txContext = daInsertCommand.ExecuteScalar();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum36" style="color:#606060;"&gt;  36:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!txContext.Equals(DBNull.Value))&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum37" style="color:#606060;"&gt;  37:&lt;/span&gt;     {&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum38" style="color:#606060;"&gt;  38:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//convert the transaction into a bytearray&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum39" style="color:#606060;"&gt;  39:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] transContext = (&lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[])txContext;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum40" style="color:#606060;"&gt;  40:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//create a photostream object to write&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum41" style="color:#606060;"&gt;  41:&lt;/span&gt;         SqlFileStream photoStream = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SqlFileStream(filePath, transContext, System.IO.FileAccess.Write);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum42" style="color:#606060;"&gt;  42:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum43" style="color:#606060;"&gt;  43:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//read the selected image as a byte array&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum44" style="color:#606060;"&gt;  44:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] imgByte = File.ReadAllBytes(selPhotoPath);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum45" style="color:#606060;"&gt;  45:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum46" style="color:#606060;"&gt;  46:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//write to the sql filestream&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum47" style="color:#606060;"&gt;  47:&lt;/span&gt;         photoStream.Write(imgByte, 0, imgByte.Length);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum48" style="color:#606060;"&gt;  48:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum49" style="color:#606060;"&gt;  49:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//close the filestream and commit transaction&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum50" style="color:#606060;"&gt;  50:&lt;/span&gt;         photoStream.Close();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum51" style="color:#606060;"&gt;  51:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum52" style="color:#606060;"&gt;  52:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum53" style="color:#606060;"&gt;  53:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//2. Insert the User record with the PhotoId&lt;/span&gt;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum54" style="color:#606060;"&gt;  54:&lt;/span&gt;         daInsertCommand.CommandText = &lt;span style="color:#006080;"&gt;"InsertUser"&lt;/span&gt;;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum55" style="color:#606060;"&gt;  55:&lt;/span&gt;         daInsertCommand.CommandType = CommandType.StoredProcedure;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum56" style="color:#606060;"&gt;  56:&lt;/span&gt;         daInsertCommand.Parameters.Add(&lt;span style="color:#006080;"&gt;"@FirstName"&lt;/span&gt;, SqlDbType.VarChar, 10);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum57" style="color:#606060;"&gt;  57:&lt;/span&gt;         daInsertCommand.Parameters.Add(&lt;span style="color:#006080;"&gt;"@LastName"&lt;/span&gt;, SqlDbType.VarChar, 10);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum58" style="color:#606060;"&gt;  58:&lt;/span&gt;         daInsertCommand.Parameters.Add(&lt;span style="color:#006080;"&gt;"@UserName"&lt;/span&gt;, SqlDbType.VarChar, 20);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum59" style="color:#606060;"&gt;  59:&lt;/span&gt;         daInsertCommand.Parameters.Add(&lt;span style="color:#006080;"&gt;"@emailAdd"&lt;/span&gt;, SqlDbType.VarChar, 100);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum60" style="color:#606060;"&gt;  60:&lt;/span&gt;         daInsertCommand.Parameters.Add(&lt;span style="color:#006080;"&gt;"@PhotoId"&lt;/span&gt;, SqlDbType.Int, 32);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum61" style="color:#606060;"&gt;  61:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum62" style="color:#606060;"&gt;  62:&lt;/span&gt;         daInsertCommand.Parameters[0].Value = txtFirstName.Text;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum63" style="color:#606060;"&gt;  63:&lt;/span&gt;         daInsertCommand.Parameters[1].Value = txtLastName.Text;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum64" style="color:#606060;"&gt;  64:&lt;/span&gt;         daInsertCommand.Parameters[2].Value = txtUserName.Text;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum65" style="color:#606060;"&gt;  65:&lt;/span&gt;         daInsertCommand.Parameters[3].Value = &lt;span style="color:#006080;"&gt;"test@add.com"&lt;/span&gt;;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum66" style="color:#606060;"&gt;  66:&lt;/span&gt;         daInsertCommand.Parameters[4].Value = PhotoId;&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum67" style="color:#606060;"&gt;  67:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum68" style="color:#606060;"&gt;  68:&lt;/span&gt;         daInsertCommand.ExecuteNonQuery();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum69" style="color:#606060;"&gt;  69:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum70" style="color:#606060;"&gt;  70:&lt;/span&gt;         daInsertCommand.Transaction.Commit();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum71" style="color:#606060;"&gt;  71:&lt;/span&gt;  &lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum72" style="color:#606060;"&gt;  72:&lt;/span&gt;     }&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum73" style="color:#606060;"&gt;  73:&lt;/span&gt; }&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum74" style="color:#606060;"&gt;  74:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt;(Exception ex)&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum75" style="color:#606060;"&gt;  75:&lt;/span&gt; {&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum76" style="color:#606060;"&gt;  76:&lt;/span&gt;     daInsertCommand.Transaction.Rollback();&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum77" style="color:#606060;"&gt;  77:&lt;/span&gt;     MessageBox.Show(ex.Message);&lt;/pre&gt;      &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span  id="lnum78" style="color:#606060;"&gt;  78:&lt;/span&gt; }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt; &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p align="justify"&gt;I have tried and added comments so that the snippet makes sense but I will re-cap the steps to insert a new file. The first thing to do is to insert an empty string value into the FILESTREAM column. This is done so that the SQL Server creates a new file on the file system.  Note that a null value does not create a file. &lt;/p&gt;&lt;p align="justify"&gt;The next thing is to get the path of the new file created and wrap it around the same transaction. This is done between lines 24 and 35. Once we get the transaction context, then writing the file is like writing to any other file on the file system.&lt;/p&gt;&lt;p align="justify"&gt;Also note the use of the SQLFileStream data type which is tightly integrated with the FILESTREAM attribute. The downside of the approach I have shown above is the number of round trips to the database. There are atleast three, one to insert the empty value into the FILESTREAM column, another one to get the path and the final trip to get the transaction context. Though I did read somewhere that this can now be reduced with the output clause I have not tried this yet. I will get around to that in a while and post an update to this post.&lt;/p&gt;&lt;p align="justify"&gt;That concludes our two part post on the FILESTREAM attribute. Though it is easy to get excited by the ability of thee FILESTREAM attribute, there are as with a lot of other things, considerations that need to be taken into account when using this. I found the below links useful for further reading&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb895334.aspx" target="_blank"&gt;Using FILESTREAM with Other SQL Server Features&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc949109.aspx" target="_blank"&gt;FILESTREAM Storage in SQL Server 2008&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://blogs.msdn.com/zowens/archive/2008/03/03/to-filestream-or-not-to-filestream-that-is-the-question.aspx" target="_blank"&gt;To FILESTREAM or not to FILESTREAM... That is the question&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-8450297254966279263?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/8450297254966279263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/sql-server-2008-filestream-part-ii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8450297254966279263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/8450297254966279263'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/sql-server-2008-filestream-part-ii.html' title='SQL Server 2008 FILESTREAM – Part – II'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_2cIm7h7Xp2w/So_Dken3unI/AAAAAAAAAHU/LCr4giyvx_s/s72-c/ImageDisplay_thumb2.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-1926362803001209653</id><published>2009-08-16T04:38:00.001-07:00</published><updated>2009-08-16T04:40:42.718-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quizzing'/><title type='text'>Landmark Quiz ‘09</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:463fb30e-628d-4ecd-9dcc-59225d7472ac" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Landmark" rel="tag"&gt;Landmark&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Quizzing" rel="tag"&gt;Quizzing&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;It was August 15th and India’s 63rd Independence Day. As with every year, the evening was consumed by the 18th edition of India’s largest open quiz: The Landmark Quiz Competition. The prelims were set to start at 2.30 P.M. The turnout was huge once more. Almost every seat in Music Academy was taken. It is not for nothing that Chennai is the quizzing capital of India and quiz enthusiasts turned out in large numbers to confirm that. If that was not enough proof, the quality of quizzing settled the matter beyond doubt. &lt;/p&gt;  &lt;p align="justify"&gt;The prelims had an interesting set of 40 questions, starting with the National Anthem rendering by the grandma granddaughter pair of Nithyashree and Late. D.k. Pattamal and closing with a question on Vikram crooning for Kanthasaamy. Try these questions &lt;/p&gt;  &lt;p align="justify"&gt;What is a bunch of bananas called? or What does the M stand for in M.R. Radha and M.L. Vasanthakumari. &lt;/p&gt;  &lt;p align="justify"&gt;You should be able to get the full list of questions on &lt;a href="http://www.quizzing.in"&gt;www.quizzing.in&lt;/a&gt; site in a short while. &lt;/p&gt;  &lt;p align="justify"&gt;The top 8 teams qualified for the Chennai finals. The team calling themselves No Enthu da won the Regional round and were crowned Chennai champions. They qualified for the National finals along with the team finishing runners up The Dhukkan Chargers. &lt;/p&gt;  &lt;p align="justify"&gt;The National Finals was another mouth-watering fare with the quiz master Dr. Navin Jayakumar raising the bar on the diffficulty of the questions and teams doing brilliantly to keep up with it. Though the teams for the national finals had qualified from three other cities, Pune, Mumbai and Bangalore, the teams comprised mostly of quizzers from Chennai. The team comprising of V.V. Ramana, Swamy and Samanth called Q.E.D walked home with the top laurels of the evening but not before they were given a run for their money by the team from Bangalore “We are like that only.” It was so close that the winner had to be decided by a tie-breaker. &lt;/p&gt;  &lt;p align="justify"&gt;Overall it was a well spent evening of quizzing and we all returned home having acquired a bit more power because “Knowledge is Power”.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3614688564147648057-1926362803001209653?l=vaideeswaranr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vaideeswaranr.blogspot.com/feeds/1926362803001209653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/landmark-quiz-09.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/1926362803001209653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3614688564147648057/posts/default/1926362803001209653'/><link rel='alternate' type='text/html' href='http://vaideeswaranr.blogspot.com/2009/08/landmark-quiz-09.html' title='Landmark Quiz ‘09'/><author><name>Vaideeswaran</name><uri>http://www.blogger.com/profile/13193265232043179983</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_2cIm7h7Xp2w/SLwzRChDj7I/AAAAAAAAABk/ZVxOEGv7FZI/S220/Andaman.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3614688564147648057.post-2905062937319634858</id><published>2009-08-13T19:51:00.001-07:00</published><updated>2009-08-22T00:25:24.079-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='How to'/><title type='text'>SQL Server 2008 FILESTREAM – Part - I</title><content type='html'>&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:eab8a500-4e07-415f-90b1-6e0f22ad7e0a" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FILESTREAM" rel="tag"&gt;FILESTREAM&lt;/a&gt;,&lt;a href="http://technorati.com/tags/How+to" rel="tag"&gt;How to&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Database" rel="tag"&gt;Database&lt;/a&gt;&lt;/div&gt;  &lt;p align="justify"&gt;There have been many a times when designing my database, I have faced this question. Should I store my files\images as BLOB or should I store it on the file system and keep a reference in the database. There has never been an easy answer to this question. Till now that is; With the FILESTREAM feature of SQL Server, the answer is “It does not matter”. &lt;/p&gt;  &lt;p align="justify"&gt;By using the FILESTREAM feature SQL Server 2008, you can store your files in the database and configure SQL Server to internally store it on the file system. This means you can make use of the large storage capacity of your file system without the overhead of having to store the path of the file in the database. In the next couple of blogs, I will try and show you how to work with the FILESTREAM feature.&lt;/p&gt;  &lt;p align="justify"&gt;To use this feature, you have to enable FILESTREAM on the SQL Server and the individual database. You can use SQL Server Configuration Services to enable FILESTREAM on your SQL Server. Go to the properties of the SQL Server instance you want to enable the feature on and go to the FILESTREAM tab. The rest of it should be self-explanatory. Enable the feature as shown below.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/_2cIm7h7Xp2w/SoTRLii2ZXI/AAAAAAAAAGY/iNmYuVtxG64/s1600-h/SQLConfig4.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SQLConfig" border="0" alt="SQLConfig" src="http://lh3.ggpht.com/_2cIm7h7Xp2w/SoTRMkQ0-0I/AAAAAAAAAGc/438gJHkB-xo/SQLConfig_thumb2.jpg?imgmax=800" width="322" height="326" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;With that done, we will now go on to configure FILESTREAM on the database. We do that with the following script&lt;/p&gt;  &lt;p&gt;EXEC sp_configure 'filestream access level', '2'    &lt;br /&gt;RECONFIGURE     &lt;br /&gt;GO &lt;/p&gt;  &lt;p align="justify"&gt;The script configures FILESTREAM access level to 2 which means you can access files with both T-SQL or streaming I/O. If you are sure you will access FILESTREAM only with T-SQL, you can set the access level to 1. Setting it to 0 disables the FILESTREAM. There is also a level ‘3’ that you use if you need Remote Access.&lt;/p&gt;  &lt;p align="justify"&gt;The next step is to indicate to the database, which folder we want SQL Server to use to store the files. To do this, you first create a SQL Server Filegroup with the following script&lt;/p&gt;  &lt;p&gt;ALTER DATABASE TestDatabase ADD FILEGROUP TestFileGroup CONTAINS FILESTREAM    &lt;br /&gt;GO &lt;/p&gt;  &lt;p align="justify"&gt;What is remaining is to configure the path in which the files for the above filegroup will be stored. You can use the below script to do the same.&lt;/p&gt;  &lt;p align="justify"&gt;ALTER DATABASE TestDatabase    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ADD FILE     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (     &lt;br /&gt;&a
