<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Raj Kaimal </title><link>http://weblogs.asp.net/rajbk/default.aspx</link><description>If it ain&amp;#39;t broke, make it better.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Adding an expression based image in a client report definition file (RDLC)</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/22/adding-an-expression-based-image-in-a-client-report-definition-file-rdlc.aspx</link><pubDate>Sat, 22 May 2010 07:03:09 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7496640</guid><dc:creator>rajbk</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7496640</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/22/adding-an-expression-based-image-in-a-client-report-definition-file-rdlc.aspx#comments</comments><description>&lt;p&gt;In previous posts, I showed you how to create a &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx"&gt;report using Visual Studio 2010&lt;/a&gt; and how to add a &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/12/adding-a-hyperlink-in-a-client-report-definition-file-rdlc.aspx"&gt;hyperlink to the report&lt;/a&gt;.&amp;#160; &lt;br /&gt;    &lt;br /&gt;In this post, I show you how to add an expression based image to each row of the report. This is similar to displaying a checkbox column for Boolean values.&amp;#160; A sample project is attached to the bottom of this post.     &lt;br /&gt;    &lt;br /&gt;To start off, download the &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-interactive-report-using-visual-studio-2010-part-3.aspx"&gt;project we created earlier from here&lt;/a&gt;.&amp;#160; The report we created had a “Discontinued” column of type Boolean. We are going to change it to display an “available” icon or “unavailable” icon based on the “Discontinued” row value.&amp;#160; &lt;br /&gt;&amp;#160;&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://weblogs.asp.net/blogs/rajbk/image_4C74F8B9.png" width="740" height="183" /&gt;     &lt;br /&gt;Load the project and double click on Products.rdlc. With the report design surface active, you will see the “Report Data” tool window. Right click on the Images folder and select “Add Image..”     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_4B9C92CF.png" width="246" height="146" /&gt;&amp;#160; &lt;br /&gt;Add the available_icon.png and discontinued_icon.png images (the sample project at the end of this post has the icon png files)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_4F3AADAC.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://weblogs.asp.net/blogs/rajbk/image_thumb_3C85B3F5.png" width="244" height="161" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;br /&gt;You can see the images we added in the “Report Data” tool window.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_14DF37CB.png" width="169" height="63" /&gt;&amp;#160; &lt;br /&gt;Drag and drop the available_icon into the “Discontinued” column row (not the header)     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_29648749.png" width="549" height="264" /&gt;     &lt;br /&gt;    &lt;br /&gt;We get a dialog box which allows us to set the image properties.     &lt;br /&gt;We will add an expression that specifies the image to display based the “Discontinued” value from the Product table. Click on the expression (fx) button.     &lt;br /&gt;&amp;#160;&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://weblogs.asp.net/blogs/rajbk/image_2C966F31.png" width="558" height="255" /&gt; &lt;/p&gt;  &lt;p&gt;Add the following expression :    &lt;br /&gt;&lt;font size="3"&gt;&lt;strong&gt;= IIf(Fields!Discontinued.Value = True, “discontinued_icon”, “available_icon”)&lt;/strong&gt;&lt;/font&gt;     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_00E5A535.png" width="524" height="98" /&gt;&amp;#160; &lt;br /&gt;Save and exit all dialog boxes.     &lt;br /&gt;In the report design surface, resize the column header and change the text from “Discontinued” to “In Production”.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_6B87EFCC.png" width="238" height="89" /&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Change Display to “Original size”    &lt;br /&gt;(Optional) Right click on the image cell (not header) , go to “Image Properties..” and offset it by 5pt from the left.&amp;#160; &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_6E85B85E.png" width="328" height="434" /&gt;     &lt;br /&gt;    &lt;br /&gt;(Optional) Change the border color since it is not set by default for image columns.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_1F4FE61E.png" width="525" height="307" /&gt; &lt;/p&gt;  &lt;p&gt;We are done adding our image column!    &lt;br /&gt;    &lt;br /&gt;Compile the application and run it. You will see that the “In Production” column has red ‘x’ icons for discontinued products. &lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_2596BCAC.png" width="635" height="364" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Download the VS 2010 sample project&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &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:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:0ffb06ed-ec48-4f3e-93a5-5af1317f7d82" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/NorthwindReportsImage2_51E27EF0.zip" target="_self" onClick="javascript: pageTracker._trackPageview('NorthwindReportsImage2.zip');"&gt;NorthwindReportsImage2.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Other Posts&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/12/adding-a-hyperlink-in-a-client-report-definition-file-rdlc.aspx"&gt;Adding a hyperlink in a client report definition file (RDLC)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx"&gt;Rendering an RDLC directly to the Response stream in ASP.NET MVC&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx"&gt;ASP.NET MVC Paging/Sorting/Filtering using the MVCContrib Grid and Pager&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/27/localization-in-asp-net-mvc-2-using-modelmetadata.aspx"&gt;Localization in ASP.NET MVC 2 using ModelMetadata&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/21/setting-up-visual-studio-2010-to-step-into-microsoft-net-source-code.aspx"&gt;Setting up Visual Studio 2010 to step into Microsoft .NET Source Code&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx"&gt;Running ASP.NET Webforms and ASP.NET MVC side by side&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx"&gt;Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7496640" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Data/default.aspx">Data</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/UI/default.aspx">UI</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Reports/default.aspx">Reports</category></item><item><title>CascadingDropDown jQuery Plugin for ASP.NET MVC</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/20/cascadingdropdown-jquery-plugin-for-asp-net-mvc.aspx</link><pubDate>Thu, 20 May 2010 06:55:38 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7491239</guid><dc:creator>rajbk</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7491239</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/20/cascadingdropdown-jquery-plugin-for-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;Cascading Drop Down is a jQuery plug-in that can be used by a select list to get automatic population using AJAX. The plug-in and a sample ASP.NET MVC project are attached at the bottom of this post. &lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_6B0A9427.png" width="502" height="99" /&gt;&amp;#160; &lt;br /&gt;&lt;strong&gt;Usage      &lt;br /&gt;&lt;/strong&gt;The code below shows two select lists :&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;select&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;id&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;=&amp;quot;customerID&amp;quot;&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;name&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;=&amp;quot;customerID&amp;quot;&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;value&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;=&amp;quot;ALFKI&amp;quot;&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;gt;&lt;/span&gt;Maria Anders&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;value&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;=&amp;quot;ANATR&amp;quot;&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;gt;&lt;/span&gt;Ana Trujillo&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;value&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;=&amp;quot;ANTON&amp;quot;&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;gt;&lt;/span&gt;Antonio Moreno&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;select&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;select&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;id&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;=&amp;quot;orderID&amp;quot;&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;name&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;=&amp;quot;orderID&amp;quot;&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;select&lt;/span&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The following code causes the second list to auto populate when a customer is selected in the first list.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;$(&lt;span style="color: #ce0202"&gt;&amp;quot;#orderID&amp;quot;&lt;/span&gt;).CascadingDropDown(&lt;span style="color: #ce0202"&gt;&amp;quot;#customerID&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;'/Sales/AsyncOrders'&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Internally, an AJAX post is made to ‘/Sales/AsyncOrders’ with the post body containing&amp;#160; customerID=[selectedCustomerID]. This executes the action AsyncOrders on the SalesController with signature AsyncOrders(string customerID).&amp;#160; The AsyncOrders method returns JSON which is then used to populate the select list. The JSON format expected is shown 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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ce0202"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;John&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ce0202"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;10326&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;},&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ce0202"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;Jane&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ce0202"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;10801&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}]&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;
    &lt;br /&gt;Details 

    &lt;br /&gt;

    &lt;br /&gt;$(targetID).CascadingDropDown(sourceID, actionPath, settings) 

    &lt;br /&gt;

    &lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;targetID&lt;/strong&gt; 

    &lt;br /&gt;The ID of the select list that will auto populate.&amp;#160; &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;sourceID 
      &lt;br /&gt;&lt;/strong&gt;The ID of the select list, which, on change, causes the targetID to auto populate. 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;actionPath 
      &lt;br /&gt;&lt;/strong&gt;The url to post to &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Options&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;promptText &lt;/strong&gt;

    &lt;br /&gt;Text for the first item in the select list 

    &lt;br /&gt;Default : -- Select -- 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;loadingText&lt;/strong&gt; 

    &lt;br /&gt;Optional text to display in the select list while it is being loaded. 

    &lt;br /&gt;Default : Loading.. 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;errorText &lt;/strong&gt;

    &lt;br /&gt;Optional text to display if an error occurs while populating the list 

    &lt;br /&gt;Default: Error loading data. 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;postData 
      &lt;br /&gt;&lt;/strong&gt;Data you want posted to the url &lt;em&gt;in place&lt;/em&gt; of the default 

    &lt;br /&gt;Example : 

    &lt;p&gt;postData: function () { 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return { prefix: $('#txtPrefix').val(), customerID: $('#customerID').val() }; 

      &lt;br /&gt;} 

      &lt;br /&gt;will cause prefix=foo&amp;amp;customerID=bar to be sent as the POST body. 

      &lt;br /&gt;Default: A text string obtained by calling &lt;a href="http://api.jquery.com/serialize/" target="_blank"&gt;serialize&lt;/a&gt; on the sourceID &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;onLoading&lt;/strong&gt; (event) 

    &lt;br /&gt;Raised before the list is populated. 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;onLoaded&lt;/strong&gt; (event) 

    &lt;br /&gt;Raised after the list is populated, The code below shows how to “&lt;a href="http://api.jquery.com/animate/" target="_blank"&gt;animate&lt;/a&gt;” the&amp;#160; select list after load. 

    &lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example using custom options:&lt;/strong&gt;&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;$(&lt;span style="color: #ce0202"&gt;&amp;quot;#orderID&amp;quot;&lt;/span&gt;).CascadingDropDown(&lt;span style="color: #ce0202"&gt;&amp;quot;#customerID&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;'/Sales/AsyncOrders'&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    promptText: &lt;span style="color: #ce0202"&gt;'-- Pick an Order--'&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    onLoading: &lt;span style="color: #006699; font-weight: bold !important"&gt;function&lt;/span&gt; () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        $(&lt;span style="color: #006699; font-weight: bold !important"&gt;this&lt;/span&gt;).css(&lt;span style="color: #ce0202"&gt;&amp;quot;background-color&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;#ff3&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    onLoaded: &lt;span style="color: #006699; font-weight: bold !important"&gt;function&lt;/span&gt; () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        $(&lt;span style="color: #006699; font-weight: bold !important"&gt;this&lt;/span&gt;).animate({ backgroundColor: &lt;span style="color: #ce0202"&gt;'#ffffff'&lt;/span&gt; }, 300);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;});&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;br /&gt;To return JSON from our action method, we use the Json &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/03/actionresult-types-in-mvc2.aspx" target="_blank"&gt;ActionResult&lt;/a&gt; passing in an IEnumerable&amp;lt;SelectListItem&amp;gt;.&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; ActionResult AsyncOrders(&lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; customerID)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;var&lt;/span&gt; orders = repository.GetOrders(customerID).ToList().Select(a =&amp;gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; SelectListItem()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Text = a.OrderDate.HasValue ? a.OrderDate.Value.ToString(&lt;span style="color: #ce0202"&gt;&amp;quot;MM/dd/yyyy&amp;quot;&lt;/span&gt;) : &lt;span style="color: #ce0202"&gt;&amp;quot;[ No Date ]&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Value = a.OrderID.ToString(),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; Json(orders);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;
    &lt;br /&gt;jQuery Plug-in 

    &lt;br /&gt;&lt;a href="http://github.com/rajkaimal/CascadingDropDown"&gt;Now hosted on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample Project using VS 2010 RTM (updated 5/21/2010) 
    &lt;br /&gt;&lt;/strong&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:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:d419364e-5760-42c6-84ec-38a65f42421d" class="wlWriterSmartContent"&gt;
  &lt;div&gt;&lt;a onclick="javascript: pageTracker._trackPageview(&amp;#39;NorthwindCascading_v0.2.zip&amp;#39;);" href="http://weblogs.asp.net/blogs/rajbk/NorthwindCascading_v0.2_50A4083C.zip" target="_self"&gt;NorthwindCascading_v0.2.zip&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;Comments and suggestions are welcome. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;Other Posts&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx" target="_blank"&gt;Rendering an RDLC directly to the Response stream in ASP.NET MVC&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx" target="_blank"&gt;Creating an ASP.NET report using Visual Studio 2010&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx" target="_blank"&gt;ASP.NET MVC Paging/Sorting/Filtering using the MVCContrib Grid and Pager&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/04/a-basic-t4-template-for-generating-model-metadata-in-asp-net-mvc2.aspx" target="_blank"&gt;A basic T4 template for generating Model Metadata in ASP.NET MVC2&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/03/actionresult-types-in-mvc2.aspx"&gt;ActionResult types in MVC2&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/27/localization-in-asp-net-mvc-2-using-modelmetadata.aspx"&gt;Localization in ASP.NET MVC 2 using ModelMetadata&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/21/setting-up-visual-studio-2010-to-step-into-microsoft-net-source-code.aspx"&gt;Setting up Visual Studio 2010 to step into Microsoft .NET Source Code&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx"&gt;Running ASP.NET Webforms and ASP.NET MVC side by side&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx"&gt;Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7491239" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/UX/default.aspx">UX</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/jQuery/default.aspx">jQuery</category></item><item><title>Running a Silverlight application in the Google App Engine platform</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/17/running-a-silverlight-application-in-the-google-app-engine-platform.aspx</link><pubDate>Mon, 17 May 2010 08:26:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7486433</guid><dc:creator>rajbk</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7486433</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/17/running-a-silverlight-application-in-the-google-app-engine-platform.aspx#comments</comments><description>&lt;p&gt;This post shows you how to host a Silverlight application in the &lt;a href="http://code.google.com/appengine/"&gt;Google App Engine&lt;/a&gt; (GAE) platform. You deploy and host your Silverlight application on Google’s infrastructure by creating a configuration file and uploading it along with your application files.     &lt;br /&gt;    &lt;br /&gt;I tested this by uploading an old demo of mine - the &lt;a href="http://weblogs.asp.net/rajbk/archive/2008/06/02/a-four-stroke-engine-in-silverlight.aspx"&gt;four stroke engine silverlight&lt;/a&gt; demo. It is currently being served by the GAE over here: &lt;a title="http://fourstrokeengine.appspot.com/" href="http://fourstrokeengine.appspot.com/"&gt;http://fourstrokeengine.appspot.com/&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;The steps to run your Silverlight application in GAE are as follows:    &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Account Creation&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Create an account at &lt;a title="http://appengine.google.com/" href="http://appengine.google.com/"&gt;http://appengine.google.com/&lt;/a&gt;. You are allocated a &lt;a href="http://code.google.com/appengine/kb/billing.html#freequota"&gt;free quota&lt;/a&gt; at signup.&lt;/p&gt;  &lt;p&gt;Select “Create an Application”    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_34799C18.png" width="549" height="140" /&gt;&amp;#160; &lt;br /&gt;Verify your account by SMS     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_5ADB7F63.png" width="385" height="218" /&gt;&amp;#160; &lt;br /&gt;Create your application by clicking on “Create an Application”     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_6C4BE03B.png" width="458" height="159" /&gt;&amp;#160; &lt;br /&gt;Pick an application identifier on the next screen. The identifier has to be unique. You will use this identifier when uploading your application. The application you create will by default be accessible at [applicationidentifier].appspot.com. You can also use custom domains if needed (refer to the docs).     &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_79B1F341.png" width="394" height="407" /&gt;&amp;#160; &lt;br /&gt;Save your application. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Download SDK&amp;#160; &lt;br /&gt;      &lt;br /&gt;&lt;/strong&gt;We will use the&amp;#160; Windows Launcher for Google App Engine tool to upload our apps (it is possible to do the same through command line). This is a GUI for creating, running and deploying applications. The launcher lets you test the app locally before deploying it to the GAE. This tool is available in the Google App Engine SDK.     &lt;br /&gt;    &lt;br /&gt;The GUI is written in Python and therefore needs an installation of Python to run.     &lt;br /&gt;Download and install the Python Binaries from here: &lt;a title="http://www.python.org/download/" href="http://www.python.org/download/"&gt;http://www.python.org/download/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Download and install the Google App Engine SDK from here: &lt;a title="http://code.google.com/appengine/downloads.html" href="http://code.google.com/appengine/downloads.html"&gt;http://code.google.com/appengine/downloads.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Run the GAE Launcher. Select Create New Application.    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_11D55D9D.png" width="312" height="190" /&gt;&amp;#160; &lt;br /&gt;On the next dialog, give your application a name (this must match the identifier we created earlier)     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_7F2063E5.png" width="264" height="179" /&gt;     &lt;br /&gt;For Parent Directory, point to the directory containing your Silverlight files. Change the port if you want to. The port is used by the GAE local web server. The server is started if you choose to run the application locally for testing purposes. Hit Save.     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Configure, Test and Upload      &lt;br /&gt;&lt;/strong&gt;    &lt;br /&gt;As shown below, the files I am interested in uploading for my Silverlight demo app are &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The html page used to host the Silverlight control &lt;/li&gt;    &lt;li&gt;The xap file containing the compiled Silverlight application &lt;/li&gt;    &lt;li&gt;A &lt;a href="The html page will be used to host the Silverlight control, the xap file contains the compiled Silverlight application and a favicon.ico file."&gt;favicon.ico&lt;/a&gt; file. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_1090C4BE.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://weblogs.asp.net/blogs/rajbk/image_thumb_5E2CF13E.png" width="232" height="67" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;We now create a configuration file for our application called app.yaml. The app.yaml file specifies how URL paths correspond to request handlers and static files.&amp;#160; We edit the file by selecting our app in the GUI and clicking “Edit”    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_2FD36B91.png" width="272" height="117" /&gt;     &lt;br /&gt;The contents of file after editing is shown below (note that the contents of the file should be in &lt;u&gt;plain text&lt;/u&gt;):&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;application: fourstrokeengine      &lt;br /&gt;version: 1       &lt;br /&gt;runtime: python       &lt;br /&gt;api_version: 1 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;handlers:      &lt;br /&gt;- url: /       &lt;br /&gt;&amp;#160; static_files: Default.html       &lt;br /&gt;&amp;#160; upload: Default.html       &lt;br /&gt;- url: /favicon.ico       &lt;br /&gt;&amp;#160; static_files: favicon.ico       &lt;br /&gt;&amp;#160; upload: favicon.ico       &lt;br /&gt;- url: /FourStrokeEngine.xap       &lt;br /&gt;&amp;#160; static_files: FourStrokeEngine.xap       &lt;br /&gt;&amp;#160; upload: FourStrokeEngine.xap       &lt;br /&gt;&amp;#160; mime_type: application/x-silverlight-app       &lt;br /&gt;- url: /.*       &lt;br /&gt;&amp;#160; static_files: Default.html       &lt;br /&gt;&amp;#160; upload: Default.html&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="courier "&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;We have listed URL patterns for our files, specified them as static files and specified a mime type for our xap file. The wild card URL at the end will match all URLs that are not found to our default page (you would normally include a html file that displays a 404 message).&amp;#160; To understand more about app.yaml, refer to &lt;a href="http://code.google.com/appengine/docs/python/config/appconfig.html"&gt;this page&lt;/a&gt;. Save the file.     &lt;br /&gt;    &lt;br /&gt;Run the application locally by selecting “Browse” in the GUI. A web server listening on the port you specified is started (8080 in my case). The app is loaded in your default web browser pointing to &lt;a href="http://localhost:8080/"&gt;http://localhost:8080/&lt;/a&gt;. Make sure the application works as expected.     &lt;br /&gt;    &lt;br /&gt;We are now ready to deploy. Click the “Deploy” icon. You will be prompted for your username and password. Hit OK. The files will get uploaded and you should get a dialog telling you to “close the window”.     &lt;br /&gt;    &lt;br /&gt;We are done uploading our Silverlight application. Go to &lt;a title="http://appengine.google.com/" href="http://appengine.google.com/"&gt;http://appengine.google.com/&lt;/a&gt; and launch the application by clicking on the link in the “Current Version” column.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_5D548B54.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://weblogs.asp.net/blogs/rajbk/image_thumb_1CB23EE5.png" width="795" height="97" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;You should be taken to a URL which points to your application running in Google’s infrastructure : &lt;a title="http://fourstrokeengine.appspot.com/" href="http://fourstrokeengine.appspot.com/"&gt;http://fourstrokeengine.appspot.com/&lt;/a&gt;.     &lt;br /&gt;    &lt;br /&gt;We are done deploying our application!     &lt;br /&gt;    &lt;br /&gt;Clicking on the link in the Application column will take you to the Admin console where you can see stats related to system usage.&amp;#160; &lt;br /&gt;    &lt;br /&gt;To learn more about the Google Application Engine, go here: &lt;a href="http://code.google.com/appengine/docs/whatisgoogleappengine.html"&gt;http://code.google.com/appengine/docs/whatisgoogleappengine.html&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7486433" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Cloud/default.aspx">Cloud</category></item><item><title>Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework - Part 2</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-2.aspx</link><pubDate>Sat, 15 May 2010 09:57:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7484673</guid><dc:creator>rajbk</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7484673</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-2.aspx#comments</comments><description>&lt;p&gt;In the &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx"&gt;previous post&lt;/a&gt;, you saw how to create an OData feed and pre-filter the data. In this post, we will see how to shape the data. A sample project is attached at the bottom of this post.     &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx"&gt;Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework - Part 1&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Shaping the feed      &lt;br /&gt;      &lt;br /&gt;&lt;/strong&gt;The Product feed we created earlier returns too much information about our products. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_20FE601B.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://weblogs.asp.net/blogs/rajbk/image_thumb_3051C22A.png" width="672" height="280" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Let’s change this so that only the following properties are returned – ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock. We also want to return only Products that are not discontinued.&amp;#160; &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Splitting the Entity      &lt;br /&gt;&lt;/strong&gt;To shape our data according to the requirements above, we are going to split our Product Entity into two and expose one through the feed. The exposed entity will contain only the properties listed above. We will use the other Entity in our Query Interceptor to pre-filter the data so that discontinued products are not returned.&lt;/p&gt;  &lt;p&gt;Go to the design surface for the Entity Model and make a copy of the Product entity. A “Product1” Entity gets created.    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_76627F3D.png" width="431" height="302" /&gt;&amp;#160; &lt;br /&gt;Rename Product1 to ProductDetail.     &lt;br /&gt;Right click on the Product entity and select “Add Association”     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_556F0C96.png" width="594" height="123" /&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Make a one to one association between Product and ProductDetails.&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_14CCC027.png" width="492" height="222" /&gt;&amp;#160; &lt;br /&gt;Keep only the properties we wish to expose on the &lt;strong&gt;Product&lt;/strong&gt; entity and delete all other properties on it (see diagram below). You delete a property on an Entity by right clicking on the property and selecting “delete”.     &lt;br /&gt;    &lt;br /&gt;Keep the ProductID on the &lt;strong&gt;ProductDetail&lt;/strong&gt;. Delete any other property on the &lt;strong&gt;ProductDetail&lt;/strong&gt; entity that is already present in the Product entity. Your design surface should look like below:     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_13F45A3D.png" width="419" height="252" /&gt;&amp;#160;&amp;#160; &lt;br /&gt;&lt;strong&gt;Mapping Entity to Database Tables&lt;/strong&gt;     &lt;br /&gt;Right click on “ProductDetail” and go to “Table Mapping”     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_53520DCD.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://weblogs.asp.net/blogs/rajbk/image_thumb_7294B4A0.png" width="230" height="211" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;Add a mapping to the “Products” table in the Mapping Details.     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_11D75B74.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://weblogs.asp.net/blogs/rajbk/image_thumb_7C79A60B.png" width="244" height="106" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;After mapping ProductDetail, you should see the following.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_30ADCF52.png" width="575" height="328" /&gt;&amp;#160; &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Add a referential constraint.      &lt;br /&gt;&lt;/strong&gt;Lets add a &lt;a href="http://blogs.msdn.com/adonet/pages/how-referential-integrity-works.aspx"&gt;referential constraint&lt;/a&gt; which is similar to a referential integrity constraint in SQL. Double click on the Association between the Entities and add the constraint with “Principal” set to “Product”.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_56A37FA8.png" width="538" height="310" /&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Let us review what we did so far.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We made a copy of the Product entity and called it ProductDetail &lt;/li&gt;    &lt;li&gt;We created a one to one association between these entities &lt;/li&gt;    &lt;li&gt;Excluding the ProductID, we made sure properties were not duplicated between these entities&amp;#160; &lt;/li&gt;    &lt;li&gt;We added a ProductDetail entity to Products table mapping (Entity to Database). &lt;/li&gt;    &lt;li&gt;We added a referential constraint between the entities. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Lets build our project. We get the following error:    &lt;br /&gt;    &lt;br /&gt;&lt;em&gt;”'NortwindODataFeed.Product' does not contain a definition for 'Discontinued' and no extension method 'Discontinued' accepting a first argument of type 'NortwindODataFeed.Product' could be found …&amp;quot;&lt;/em&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;The reason for this error is because our Product Entity no longer has a “Discontinued” property. We “moved” it to the ProductDetail entity since we want our Product Entity to contain only properties that will be exposed by our feed. Since we have a one to one association between the entities, we can easily rewrite our Query Interceptor like so:&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[QueryInterceptor(&amp;quot;Products&amp;quot;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; Expression&amp;lt;Func&amp;lt;Product, bool&amp;gt;&amp;gt; OnReadProducts()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; o =&amp;gt; o.ProductDetail.Discontinued == &lt;span style="color: #006699; font-weight: bold !important"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Similarly, all “hidden” properties of the Product table are available to us internally (through the ProductDetail Entity) for any additional logic we wish to implement. 
  &lt;br /&gt;

  &lt;br /&gt;Compile the project and view the feed. We see that the feed returns only the properties that were part of the requirement. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_27DDC706.png" width="632" height="191" /&gt;&amp;#160; &lt;br /&gt;

  &lt;br /&gt;To see the data in JSON format, you have to create a request with the following request header (easy to do with jQuery) 

  &lt;br /&gt;&lt;strong&gt;Accept: application/json, text/javascript, */* 
    &lt;br /&gt;&lt;/strong&gt;

  &lt;br /&gt;The response will look like this:&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ce0202"&gt;&amp;quot;d&amp;quot;&lt;/span&gt; : {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ce0202"&gt;&amp;quot;results&amp;quot;&lt;/span&gt;: [&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ce0202"&gt;&amp;quot;__metadata&amp;quot;&lt;/span&gt;: {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ce0202"&gt;&amp;quot;uri&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;http://localhost.:2576/DataService.svc/Products(1)&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;NorthwindModel.Product&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}, &lt;span style="color: #ce0202"&gt;&amp;quot;ProductID&amp;quot;&lt;/span&gt;: 1, &lt;span style="color: #ce0202"&gt;&amp;quot;ProductName&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;Chai&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;QuantityPerUnit&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;10 boxes x 20 bags&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;UnitPrice&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;18.0000&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;UnitsInStock&amp;quot;&lt;/span&gt;: 39&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}, {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ce0202"&gt;&amp;quot;__metadata&amp;quot;&lt;/span&gt;: {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ce0202"&gt;&amp;quot;uri&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;http://localhost.:2576/DataService.svc/Products(2)&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;NorthwindModel.Product&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}, &lt;span style="color: #ce0202"&gt;&amp;quot;ProductID&amp;quot;&lt;/span&gt;: 2, &lt;span style="color: #ce0202"&gt;&amp;quot;ProductName&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;Chang&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;QuantityPerUnit&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;24 - 12 oz bottles&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;UnitPrice&amp;quot;&lt;/span&gt;: &lt;span style="color: #ce0202"&gt;&amp;quot;19.0000&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;UnitsInStock&amp;quot;&lt;/span&gt;: 17&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}, {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If anyone has the &lt;a href="http://msdn.microsoft.com/en-us/library/dd728283.aspx"&gt;$format&lt;/a&gt; operation working, please post a comment. It was not working for me at the time of writing this.&amp;#160; &lt;br /&gt;

  &lt;br /&gt;We have successfully pre-filtered our data to expose only products that have not been discontinued and shaped our data so that only certain properties of the Entity are exposed. Note that there are several other ways you could implement this like creating a &lt;a href="http://msdn.microsoft.com/en-us/library/cc716798.aspx"&gt;QueryView&lt;/a&gt;, Stored Procedure or &lt;a href="http://msdn.microsoft.com/en-us/library/cc982038.aspx"&gt;DefiningQuery&lt;/a&gt;. 

  &lt;br /&gt;

  &lt;br /&gt;You have seen how easy it is to create an OData feed, shape the data and pre-filter it by hardly writing any code of your own. &lt;/p&gt;

&lt;p&gt;For more details on OData, check out the blog of one of the most passionate Architects I have ever met, &lt;a href="http://blogs.msdn.com/pablo/"&gt;Pablo Castro&lt;/a&gt; – the Architect of &lt;strike&gt;Aristoria&lt;/strike&gt; WCF Data Services. 

  &lt;br /&gt;In addition, watch his MIX 2010 presentation titled “OData: There's a Feed for That” &lt;a href="http://live.visitmix.com/MIX10/Sessions/FT12"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;strong&gt;Download Sample Project for VS 2010 RTM. &lt;/strong&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:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:bc3364f2-928f-4159-98db-45af38ae4047" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/NortwindODataFeed_00374ADC.zip" target="_self" onClick="javascript: pageTracker._trackPageview('NortwindODataFeed.zip');"&gt;NortwindODataFeed.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Make sure you have the right &lt;a href="http://msdn.microsoft.com/en-us/library/cc716756.aspx"&gt;Entity Connection String&lt;/a&gt;. Depending on how you have your server/user set up, you may have to include the Catalog name like so:&lt;/p&gt;

&lt;p&gt;…\sqlexpress;&lt;strong&gt;Initial Catalog=Northwind&lt;/strong&gt;;Integrated Security=True;MultipleActiveResultSets=True&amp;amp;quot;&amp;quot; …&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;Tip: To debug your feed, add config.UseVerboseErrors in the InitializeService method.

  &lt;br /&gt;Pop Quiz: What happens when we add this &lt;font size="2" face="conso"&gt;config.SetEntitySetAccessRule(&amp;quot;&lt;strong&gt;ProductDetails&lt;/strong&gt;&amp;quot;, EntitySetRights.AllRead); ?&lt;/font&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7484673" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/OData/default.aspx">OData</category></item><item><title>Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework - Part 1</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx</link><pubDate>Sat, 15 May 2010 09:49:44 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7484666</guid><dc:creator>rajbk</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7484666</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;The &lt;/em&gt;&lt;a href="http://www.odata.org/"&gt;&lt;em&gt;Open Data Protocol&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, referred to as &lt;strong&gt;OData&lt;/strong&gt;, is a new data-sharing standard that breaks down silos and fosters an interoperative ecosystem for data consumers (clients) and producers (services) that is far more powerful than currently possible. It enables more applications to make sense of a broader set of data, and helps every data service and client add value to the whole ecosystem. &lt;strong&gt;WCF Data Services&lt;/strong&gt; (previously known as ADO.NET Data Services), then, was the first Microsoft technology to support the Open Data Protocol in Visual Studio 2008 SP1. It provides developers with client libraries for .NET, Silverlight, AJAX, PHP and Java. Microsoft now also supports OData in SQL Server 2008 R2, Windows Azure Storage, Excel 2010 (through PowerPivot), and SharePoint 2010. Many other other applications in the works&lt;/em&gt;. *     &lt;br /&gt;    &lt;br /&gt;This post walks you through how to create an OData feed, define a shape for the data and pre-filter the data using Visual Studio 2010, WCF Data Services and the Entity Framework. A sample project is attached at the bottom of &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-2.aspx"&gt;Part 2&lt;/a&gt; of this post.     &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-2.aspx"&gt;Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework - Part 2&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Create the Web Application&lt;/strong&gt;&lt;strong&gt;      &lt;br /&gt;&lt;/strong&gt;File –› New –› Project, Select “ASP.NET Empty Web Application”&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_20291211.png" width="244" height="139" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Add the Entity Data Model&lt;/strong&gt;     &lt;br /&gt;Right click on the Web Application in the Solution Explorer and select “Add New Item..”     &lt;br /&gt;Select “ADO.NET Entity Data Model” under &amp;quot;Data”. Name the Model “Northwind” and click “Add”.     &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_384C7C6C.png" width="244" height="139" /&gt;&amp;#160; &lt;br /&gt;In the “Choose Model Contents”, select “Generate Model From Database” and click “Next”&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_708AF384.png" width="273" height="226" /&gt;&amp;#160; &lt;br /&gt;Define a connection to your database containing the Northwind database in the next screen.&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_7DF1068A.png" width="244" height="103" /&gt; &lt;/p&gt;  &lt;p&gt;We are going to expose the Products table through our OData feed. Select “Products” in the “Choose your Database Object” screen.&lt;/p&gt;  &lt;p&gt;&amp;#160;&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://weblogs.asp.net/blogs/rajbk/image_7D18A0A0.png" width="330" height="76" /&gt; &lt;/p&gt;  &lt;p&gt;Click “Finish”. We are done creating our Entity Data Model. Save the Northwind.edmx file created.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Add the WCF Data Service      &lt;br /&gt;&lt;/strong&gt;Right click on the Web Application in the Solution Explorer and select “Add New Item..”     &lt;br /&gt;Select “WCF Data Service” from the list and call the service “DataService” (creative, huh?). Click “Add”.     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_7CAC6DAB.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://weblogs.asp.net/blogs/rajbk/image_thumb_5BB8FB04.png" width="379" height="349" /&gt;&lt;/a&gt;&lt;strong&gt;&amp;#160; &lt;br /&gt;Enable Access to the Data Service       &lt;br /&gt;&lt;/strong&gt;Open the DataService.svc.cs class. The class is well commented and instructs us on the next steps. &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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; DataService : DataService&amp;lt; &lt;span style="color: #008000"&gt;/* TODO: put your data source class name here */&lt;/span&gt; &amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// This method is called only once to initialize service-wide policies.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;static&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;void&lt;/span&gt; InitializeService(DataServiceConfiguration config)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// Examples:&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// config.SetEntitySetAccessRule(&amp;quot;MyEntityset&amp;quot;, EntitySetRights.AllRead);&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// config.SetServiceOperationAccessRule(&amp;quot;MyServiceOperation&amp;quot;, ServiceOperationRights.All);&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Replace the comment that starts with “/* TODO:” with “NorthwindEntities” (the entity container name of the Model we created earlier).&amp;#160; &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;WCF Data Services is initially locked down by default, FTW! &lt;/strong&gt;No data is exposed without you explicitly setting it. You have explicitly specify which Entity sets you wish to expose and what rights are allowed by using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.services.idataserviceconfiguration.setentitysetaccessrule.aspx"&gt;SetEntitySetAccessRule&lt;/a&gt;. The &lt;a href="http://blogs.msdn.com/marcelolr/archive/2008/01/21/service-operations-in-ado-net-data-services.aspx"&gt;SetServiceOperationAccessRule&lt;/a&gt; on the other hand sets rules for a specified operation&lt;strong&gt;. 
    &lt;br /&gt;&lt;/strong&gt;

  &lt;br /&gt;Let us define an access rule to expose the Products Entity we created earlier. We use the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.services.entitysetrights.aspx"&gt;EnititySetRights.AllRead&lt;/a&gt; since we want to give read only access. Our modified code is shown 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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; DataService : DataService&amp;lt;NorthwindEntities&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;static&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;void&lt;/span&gt; InitializeService(DataServiceConfiguration config)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        config.SetEntitySetAccessRule(&lt;span style="color: #ce0202"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, EntitySetRights.AllRead);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;We are done setting up our ODataFeed! Compile your project. Right click on DataService.svc and select “View in Browser” to see the OData feed. 
  &lt;br /&gt;

  &lt;br /&gt;To view the feed in IE, you must make sure that &amp;quot;Feed Reading View&amp;quot; is turned off. You set this under Tools -› Internet Options -› Content tab. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_0CD835A5.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://weblogs.asp.net/blogs/rajbk/image_thumb_032FC76F.png" width="244" height="112" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;If you navigate to “Products”, you should see the Products feed. Note also that URIs are &lt;strong&gt;case sensitive.&lt;/strong&gt; ie. Products work but products doesn’t. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_02576185.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://weblogs.asp.net/blogs/rajbk/image_thumb_3B219585.png" width="244" height="112" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;Filtering our data 
    &lt;br /&gt;&lt;/strong&gt;OData has a set of system query operations you can use to perform common operations against data exposed by the model. For example, to see only Products in CategoryID 2, we can use the following request: 

  &lt;br /&gt;

  &lt;br /&gt;/DataService.svc/Products?&lt;strong&gt;$filter=CategoryID eq 2 
    &lt;br /&gt;&lt;/strong&gt;

  &lt;br /&gt;At the time of this writing, &lt;a href="http://msdn.microsoft.com/en-us/library/dd728283.aspx"&gt;supported operations&lt;/a&gt; are $orderby, $top, $skip, $filter, $expand, $format†, $select, $inlinecount. 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-filtering our data using Query Interceptors 
    &lt;br /&gt;&lt;/strong&gt;The Product feed currently returns all Products. We want to change that so that it contains only Products that have not been discontinued. 

  &lt;br /&gt;

  &lt;br /&gt;WCF introduces the concept of &lt;a href="http://msdn.microsoft.com/en-us/library/dd744842.aspx"&gt;interceptors&lt;/a&gt; which allows us to inject custom validation/policy logic into the request/response pipeline of a WCF data service. 

  &lt;br /&gt;

  &lt;br /&gt;We will use a QueryInterceptor to pre-filter the data so that it returns only Products that are not discontinued. To &lt;a href="http://msdn.microsoft.com/en-us/library/dd744837.aspx"&gt;create&lt;/a&gt; a QueryInterceptor, write a method that returns an &lt;font size="2" face="Consolas"&gt;Expression&amp;lt;Func&amp;lt;T, bool&amp;gt;&amp;gt;&lt;/font&gt; and mark it with the QueryInterceptor &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.services.queryinterceptorattribute.aspx"&gt;attribute&lt;/a&gt; as shown 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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[QueryInterceptor(&amp;quot;Products&amp;quot;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; Expression&amp;lt;Func&amp;lt;Product, bool&amp;gt;&amp;gt; OnReadProducts()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; o =&amp;gt; o.Discontinued == &lt;span style="color: #006699; font-weight: bold !important"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Viewing the feed after compilation will only show products that have not been discontinued. We also confirm this by looking at the WHERE clause in the SQL generated by the entity framework.&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;SELECT&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[Extent1].[ProductID] &lt;span style="color: #006699; font-weight: bold !important"&gt;AS&lt;/span&gt; [ProductID], &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;... &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[Extent1].[Discontinued] &lt;span style="color: #006699; font-weight: bold !important"&gt;AS&lt;/span&gt; [Discontinued]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;FROM&lt;/span&gt; [dbo].[Products] &lt;span style="color: #006699; font-weight: bold !important"&gt;AS&lt;/span&gt; [Extent1]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;WHERE&lt;/span&gt; 0 = [Extent1].[Discontinued]&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Other examples of Query/Change interceptors can be seen &lt;a href="http://msdn.microsoft.com/en-us/library/dd744837.aspx"&gt;here&lt;/a&gt; including an example to filter data based on the identity of the authenticated user. 

  &lt;br /&gt;

  &lt;br /&gt;We are done pre-filtering our data. In the next part of this post, we will see how to shape our data. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-2.aspx"&gt;Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework - Part 2&lt;/a&gt; 

  &lt;br /&gt;

  &lt;br /&gt;&lt;u&gt;Foot Notes&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;* &lt;a title="http://msdn.microsoft.com/en-us/data/aa937697.aspx" href="http://msdn.microsoft.com/en-us/data/aa937697.aspx"&gt;http://msdn.microsoft.com/en-us/data/aa937697.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;† $format did not work for me. The way to get a Json response is to include the following in the&amp;#160; request header “Accept: application/json, text/javascript, */*” when making the request. This is easily done with most JavaScript libraries.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7484666" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/OData/default.aspx">OData</category></item><item><title>Adding a hyperlink in a client report definition file (RDLC)</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/12/adding-a-hyperlink-in-a-client-report-definition-file-rdlc.aspx</link><pubDate>Thu, 13 May 2010 03:34:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7481393</guid><dc:creator>rajbk</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7481393</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/12/adding-a-hyperlink-in-a-client-report-definition-file-rdlc.aspx#comments</comments><description>&lt;p&gt;This post shows you how to add a hyperlink to your RDLC report. In a &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx"&gt;previous post&lt;/a&gt;, I showed you how to create an RDLC report.    &lt;br /&gt;    &lt;br /&gt;We have been given the requirement to the report &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx"&gt;we created earlier&lt;/a&gt;, the Northwind Product report, to add a column that will contain hyperlinks which are unique per row.&amp;#160; The URLs will be RESTful with the ProductID at the end.    &lt;br /&gt;    &lt;br /&gt;Clicking on the URL will take them to a website like so: &lt;a href="http://localhost/products/3"&gt;http://localhost/products/3&lt;/a&gt;&amp;#160; where 3 is the primary key of the product row clicked on.     &lt;br /&gt;    &lt;br /&gt;To start off, open the RDLC and add a new column to the product table.&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_3B07A164.png" width="355" height="115" /&gt;&amp;#160; &lt;br /&gt;Add text to the header (Details) and row (Product Website).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_486DB46A.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://weblogs.asp.net/blogs/rajbk/image_thumb_681C8E32.png" width="150" height="70" /&gt;&lt;/a&gt;     &lt;br /&gt;Right click on the row (not header) and select “TextBox properties”    &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_20C73840.png" width="282" height="250" /&gt;     &lt;br /&gt;    &lt;br /&gt;Select Action – Go to URL. You could hard code a URL here but what we need is a URL that changes based on the ProductID.    &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_67442848.png" width="589" height="536" /&gt;&amp;#160; &lt;br /&gt;Click on the expression button (fx)&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_2635A8E4.png" width="554" height="504" /&gt;     &lt;br /&gt;The expression builder gives you access to several functions and constants including the fields in your dataset. See this reference for more details: &lt;a href="http://msdn.microsoft.com/en-us/library/ms251668(v=VS.80).aspx"&gt;Common Expressions for ReportViewer Reports&lt;/a&gt;.    &lt;br /&gt;    &lt;br /&gt;Add the following expression:    &lt;br /&gt;    &lt;br /&gt;= &amp;quot;&lt;a href="http://localhost/products/&amp;quot;"&gt;http://localhost/products/&amp;quot;&lt;/a&gt;&lt;strong&gt; &amp;amp; Fields!ProductID.Value&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Click OK to exit the Expression Builder.   &lt;br /&gt;    &lt;br /&gt;The report will not render because hyperlinks are disabled by default in the ReportViewer control. To enable it, add the following in your page load event (where rvProducts is the ID of your ReportViewerControl):&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;protected&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: #006699; font-weight: bold !important"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (!IsPostBack)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        rvProducts.LocalReport.EnableHyperlinks = &lt;span style="color: #006699; font-weight: bold !important"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;We want our links to open in a new window so set the HyperLinkTarget property of the ReportViewer control to “_blank”
  &lt;br /&gt;

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_450C1CC2.png" width="259" height="82" /&gt;&amp;#160; &lt;br /&gt;We are done adding hyperlinks to our report. Clicking on the links for each product pops open a new windows. The URL has the ProductID added at the end.&lt;/p&gt;

&lt;p&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://weblogs.asp.net/blogs/rajbk/image_2FAE675A.png" width="328" height="90" /&gt; 

  &lt;br /&gt;

  &lt;br /&gt;Enjoy!

  &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7481393" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Reports/default.aspx">Reports</category></item><item><title>Pages in IE render differently when served through the ASP.NET Development server and Production Server</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/12/pages-in-ie-render-differently-when-served-through-the-asp-net-development-server-and-production-server.aspx</link><pubDate>Wed, 12 May 2010 15:41:55 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7480687</guid><dc:creator>rajbk</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7480687</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/12/pages-in-ie-render-differently-when-served-through-the-asp-net-development-server-and-production-server.aspx#comments</comments><description>&lt;p&gt;You see differences in the way IE renders your web application locally on the ASP.NET Development server compared to your production server. Comparing the response from both servers including response headers and CSS show no difference.    &lt;br /&gt;    &lt;br /&gt;The issue may occur because of a setting in IE. In IE, go to Tools –&amp;gt; Compatibility ViewSettings.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_070B3CD3.png" width="398" height="461" /&gt;     &lt;br /&gt;&lt;/p&gt; The checkbox “Display intranet sites in Compatibility View” turned on forces IE8 to display the web application content in a way similar to how Internet Explorer 7 handles standards mode web pages. Since your local web server is considered to be in the intranet zone, IE uses “Compatibility View” to render your pages.   &lt;br /&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_1F9ADA23.png" width="444" height="49" /&gt;     &lt;br /&gt;    &lt;br /&gt;While you could uncheck this setting in or propagate the change to all developers through group policy settings, a different way is described below.&lt;/p&gt;  &lt;p&gt;To force IE to mimic the behavior of a certain version of IE when rendering the pages, you use the meta element&amp;#160; to include a “X-UA-Compatible” http-equiv header in&amp;#160; your web page or have it sent as part of the header by adding it to your web.config file. The values are listed 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: consolas, &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: consolas, &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: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;meta&lt;/span&gt; &lt;span style="color: #900"&gt;http-equiv&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;content&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;IE=4&amp;quot;&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt;   &lt;span style="color: #008000"&gt;&amp;lt;!-- IE5 mode --&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;meta&lt;/span&gt; &lt;span style="color: #900"&gt;http-equiv&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;content&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;IE=7.5&amp;quot;&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #008000"&gt;&amp;lt;!-- IE7 mode --&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;meta&lt;/span&gt; &lt;span style="color: #900"&gt;http-equiv&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;content&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;IE=100&amp;quot;&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #008000"&gt;&amp;lt;!-- IE8 mode --&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;meta&lt;/span&gt; &lt;span style="color: #900"&gt;http-equiv&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;content&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;IE=a&amp;quot;&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt;   &lt;span style="color: #008000"&gt;&amp;lt;!-- IE5 mode --&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This value can also be set in web.config like so:&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: consolas, &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: consolas, &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: consolas, &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: #900"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #900"&gt;version&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;encoding&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt;?&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.webServer&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;httpProtocol&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;customHeaders&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;clear&lt;/span&gt; &lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;add&lt;/span&gt; &lt;span style="color: #900"&gt;name&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;value&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;IE=EmulateIE7&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;customHeaders&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;httpProtocol&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.webServer&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;configuration&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;br /&gt;The setting can added in the IIS metabase as described &lt;a href="http://msdn.microsoft.com/en-us/library/cc817572.aspx"&gt;here&lt;/a&gt;. 

  &lt;br /&gt;

  &lt;br /&gt;Similarly, you can do the same in Apache by adding the directive in httpd.conf&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: consolas, &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: consolas, &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: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Location&lt;/span&gt; /&lt;span style="color: #900"&gt;store&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;   Header set X-UA-Compatible “IE=EmulateIE7”&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Location&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Even though it can be done on a site level, I recommend you do it on a per application level to avoid confusing the developer. 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References &lt;/strong&gt;

  &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx"&gt;Defining Document Compatibility&lt;/a&gt; 

  &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc817572.aspx"&gt;Implementing the META Switch on IIS&lt;/a&gt; 

  &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc817573.aspx"&gt;Implementing the META Switch on Apache&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7480687" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/IIS/default.aspx">IIS</category></item><item><title>Running ASP.NET Webforms and ASP.NET MVC side by side</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx</link><pubDate>Tue, 11 May 2010 10:10:45 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7479048</guid><dc:creator>rajbk</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7479048</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx#comments</comments><description>&lt;p&gt;One of the nice things about ASP.NET MVC and its older brother ASP.NET WebForms is that they are both built on top of the ASP.NET runtime environment. The advantage of this is that, you can still run them side by side even though MVC and WebForms are different frameworks. &lt;/p&gt;  &lt;p&gt;Another point to note is that with the release of the ASP.NET routing in .NET 3.5 SP1, we are able to create SEO friendly URLs that do not map to specific files on disk. The routing is part of the core runtime environment and therefore can be used by both WebForms and MVC.    &lt;br /&gt;    &lt;br /&gt;To run both frameworks side by side, we could easily create a separate folder in your MVC project for all our WebForm files and be good to go. What this post shows you instead, is how to have an MVC application with WebForm pages&amp;#160; that both use a &lt;strong&gt;common master page&lt;/strong&gt; and &lt;strong&gt;common routing for SEO&lt;/strong&gt; friendly URLs.&amp;#160; &lt;br /&gt;    &lt;br /&gt;A sample project that shows WebForms and MVC running side by side is attached at the bottom of this post.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;So why would we want to run WebForms and MVC in the same project?&lt;/strong&gt;&amp;#160; &lt;br /&gt;    &lt;br /&gt;WebForms come with a lot of server controls that provide a lot of rich functionality. One example is the ReportViewer control. Using this control and client report definition files (RDLC), we can create rich interactive reports (with charting controls). I show you how to use the ReportViewer control in a WebForm project here :&amp;#160; &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx"&gt;Creating an ASP.NET report using Visual Studio 2010&lt;/a&gt;. We can create even more advanced reports by using SQL reporting services that can also be rendered by the ReportViewer control. &lt;/p&gt;  &lt;p&gt;Moving along, consider the sample MVC application I blogged about titled : &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx"&gt;ASP.NET MVC Paging/Sorting/Filtering using the MVCContrib Grid and Pager&lt;/a&gt;. Assume you were given the requirement to add a UI to the MVC application where users could interact with a report and be given the option to export the report to Excel, PDF or Word. How do you go about doing it?&amp;#160;&amp;#160; &lt;br /&gt;    &lt;br /&gt;This is a perfect scenario to use the ReportViewer control and RDLCs. As you saw in the post on creating the &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx"&gt;ASP.NET report&lt;/a&gt;, the ReportViewer control is a Web Control and is designed to be run in a WebForm project with dependencies on, amongst others, a ScriptManager control and the beloved &lt;a href="http://twitter.com/__viewstate"&gt;Viewstate&lt;/a&gt;.&amp;#160; &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_0BD8C84C.png" width="504" height="197" /&gt;     &lt;br /&gt;    &lt;br /&gt;Since MVC and WebForm both run under the same runtime, the easiest thing to is to add the WebForm application files (index.aspx, rdlc, related class files) into our MVC project. We will copy the files over from the WebForm project into the MVC project.     &lt;br /&gt;    &lt;br /&gt;Create a new folder in our MVC application called CommonReports. Add the index.aspx and rdlc file from the Webform project&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_62EDB342.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://weblogs.asp.net/blogs/rajbk/image_thumb_777302C0.png" width="161" height="60" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;Right click on the Index.aspx file and convert it to a web application. This will add the index.aspx.designer.cs file (this step is not required if you are manually adding a WebForm aspx file into the MVC project).     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_49197D13.png" width="231" height="247" /&gt;&amp;#160;&amp;#160; &lt;br /&gt;Verify that all the type names for the ObjectDataSources in code behind to point to the correct ProductRepository and fix any compiler errors. Right click on Index.aspx and select “View in browser”. You should see a screen like the one below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_087730A4.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://weblogs.asp.net/blogs/rajbk/image_thumb_209A9AFF.png" width="498" height="345" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;There are two issues with our page. &lt;font color="#ff0000"&gt;It does not use our site master page and the URL is not SEO friendly.&lt;/font&gt;     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Common Master Page &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The easiest way to use master pages with both MVC and WebForm pages is to have a common master page that each inherits from as shown below.    &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_7FA72857.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://weblogs.asp.net/blogs/rajbk/image_thumb_0D0D3B5E.png" width="254" height="153" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;The reason for this is most WebForm controls require them to be inside a Form control and require ControlState or ViewState. ViewMasterPages used in MVC, on the other hand, are designed to be used with content pages that derive from ViewPage with Viewstate turned off. By having a separate master page for MVC and WebForm that inherit from the Root master page,, we can set properties that are specific to each. For example, in the Webform master, we can turn on ViewState, add a form tag etc.     &lt;br /&gt;    &lt;br /&gt;Another point worth noting is that if you set a WebForm page to use a MVC site master page, you may run into errors like the following:     &lt;br /&gt;    &lt;br /&gt;&lt;font size="2" face="Consolas"&gt;A ViewMasterPage can be used only with content pages that derive from ViewPage or ViewPage&amp;lt;TViewItem&amp;gt;&lt;/font&gt;     &lt;br /&gt;    &lt;br /&gt;or&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Consolas"&gt;Control 'MainContent_MyButton' of type 'Button' must be placed inside a form tag with runat=server.&lt;/font&gt;     &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Since the ViewMasterPage inherits from MasterPage as seen below, we make our Root.master inherit from MasterPage, MVC.master inherit from ViewMasterPage and Webform.master inherits from MasterPage.    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_0581CBF1.png" width="350" height="113" /&gt;     &lt;br /&gt;We define the attributes on the master pages like so:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Root.master&lt;/strong&gt;       &lt;br /&gt;&lt;font size="2" face="Consolas"&gt;&amp;lt;%@ Master Inherits=&amp;quot;&lt;strong&gt;&lt;font color="#ff0000"&gt;System.Web.UI.MasterPage&lt;/font&gt;&lt;/strong&gt;&amp;quot;&amp;#160; … %&amp;gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;MVC.master&lt;/strong&gt;       &lt;br /&gt;&lt;font size="2" face="Consolas"&gt;&amp;lt;%@ Master MasterPageFile=&amp;quot;~/Views/Shared/Root.Master&amp;quot; Inherits=&amp;quot;&lt;font color="#ff0000"&gt;System.Web.Mvc.ViewMasterPage&lt;/font&gt;&amp;quot; … %&amp;gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;WebForm.master        &lt;br /&gt;&lt;/strong&gt;&lt;font size="2" face="Consolas"&gt;&amp;lt;%@ Master MasterPageFile=&amp;quot;~/Views/Shared/Root.Master&amp;quot; Inherits=&amp;quot;NorthwindSales.Views.Shared.&lt;font color="#ff0000"&gt;Webform&lt;/font&gt;&amp;quot; %&amp;gt;         &lt;br /&gt;&lt;/font&gt;Code behind:       &lt;br /&gt;&lt;font size="2" face="Consolas"&gt;public partial class &lt;font color="#ff0000"&gt;Webform&lt;/font&gt; : &lt;font color="#ff0000"&gt;System.Web.UI.MasterPage&lt;/font&gt; {}&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;We make changes to our reports aspx file to use the Webform.master. See the source of the master pages in the sample project for a better understanding of how they are connected.    &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;SEO friendly links      &lt;br /&gt;      &lt;br /&gt;&lt;/strong&gt;We want to create SEO friendly links that point to our report. A request to /Reports/Products should render the report located in ~/CommonReports/Products.aspx. Simillarly to support future reports, a request to /Reports/Sales should render a report in ~/CommonReports/Sales.aspx.     &lt;br /&gt;    &lt;br /&gt;Lets start by renaming our index.aspx file to Products.aspx to be consistent with our routing criteria above.     &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_3302EBB4.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://weblogs.asp.net/blogs/rajbk/image_thumb_1DA5364C.png" width="174" height="152" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;As mentioned earlier, since routing is part of the core runtime environment, we ca easily create a custom route for our reports by adding an entry in Global.asax. &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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;static&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;void&lt;/span&gt; RegisterRoutes(RouteCollection routes)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    routes.IgnoreRoute(&lt;span style="color: #ce0202"&gt;&amp;quot;{resource}.axd/{*pathInfo}&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;//Custom route for reports&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    routes.MapPageRoute(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;span style="color: #ce0202"&gt;&amp;quot;ReportRoute&amp;quot;&lt;/span&gt;,                         &lt;span style="color: #008000"&gt;// Route name&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;span style="color: #ce0202"&gt;&amp;quot;Reports/{reportname}&amp;quot;&lt;/span&gt;,                &lt;span style="color: #008000"&gt;// URL&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;span style="color: #ce0202"&gt;&amp;quot;~/CommonReports/{reportname}.aspx&amp;quot;&lt;/span&gt;   &lt;span style="color: #008000"&gt;// File&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     );&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    routes.MapRoute(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ce0202"&gt;&amp;quot;Default&amp;quot;&lt;/span&gt;,                          &lt;span style="color: #008000"&gt;// Route name&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ce0202"&gt;&amp;quot;{controller}/{action}/{id}&amp;quot;&lt;/span&gt;,       &lt;span style="color: #008000"&gt;// URL with 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: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            controller = &lt;span style="color: #ce0202"&gt;&amp;quot;Home&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            action = &lt;span style="color: #ce0202"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            id = UrlParameter.Optional&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }                                   &lt;span style="color: #008000"&gt;// Parameter defaults&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    );&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;With our custom route in place, a request to Reports/Employees will render the page at ~/CommonReports/Employees.aspx. We make this custom route the first entry since the routing system walks the table from top to bottom, and the first route to match wins. &lt;strong&gt;Note that it is highly recommended that you write unit tests for your routes to ensure that the mappings you defined are correct. &lt;/strong&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;Common Menu Structure&lt;/strong&gt; 

  &lt;br /&gt;The master page in our original MVC project had a menu structure like so:&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;ul id=&lt;span style="color: #ce0202"&gt;&amp;quot;menu&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;%=Html.ActionLink(&lt;span style="color: #ce0202"&gt;&amp;quot;Home&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;Home&amp;quot;&lt;/span&gt;) %&amp;gt;&amp;lt;/li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;%=Html.ActionLink(&lt;span style="color: #ce0202"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;) %&amp;gt;&amp;lt;/li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;%=Html.ActionLink(&lt;span style="color: #ce0202"&gt;&amp;quot;Help&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;Help&amp;quot;&lt;/span&gt;, &lt;span style="color: #ce0202"&gt;&amp;quot;Home&amp;quot;&lt;/span&gt;) %&amp;gt;&amp;lt;/li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;/ul&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;We want this menu structure to be common to all pages/views and hence should reside in Root.master. Unfortunately the Html.ActionLink helpers will not work since Root.master inherits from MasterPage which does not have the helper methods available. 
  &lt;br /&gt;

  &lt;br /&gt;The quickest way to resolve this issue is to use &lt;a href="http://msdn.microsoft.com/en-us/library/dd329551.aspx"&gt;RouteUrl expressions&lt;/a&gt;. Using&amp;#160; RouteUrl expressions, we can programmatically generate URLs that are based on route definitions. By specifying parameter values and a route name if required, we get back a URL string that corresponds to a matching route. 

  &lt;br /&gt;We move our menu structure to Root.master and change it to use RouteUrl expressions:&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;ul id=&lt;span style="color: #ce0202"&gt;&amp;quot;menu&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;asp:HyperLink ID=&lt;span style="color: #ce0202"&gt;&amp;quot;hypHome&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; NavigateUrl=&lt;span style="color: #ce0202"&gt;&amp;quot;&amp;lt;%$RouteUrl:routename=default,controller=home,action=index%&amp;gt;&amp;quot;&lt;/span&gt;&amp;gt;Home&amp;lt;/asp:HyperLink&amp;gt;&amp;lt;/li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;asp:HyperLink ID=&lt;span style="color: #ce0202"&gt;&amp;quot;hypProducts&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; NavigateUrl=&lt;span style="color: #ce0202"&gt;&amp;quot;&amp;lt;%$RouteUrl:routename=default,controller=products,action=index%&amp;gt;&amp;quot;&lt;/span&gt;&amp;gt;Products&amp;lt;/asp:HyperLink&amp;gt;&amp;lt;/li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;asp:HyperLink ID=&lt;span style="color: #ce0202"&gt;&amp;quot;hypReport&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; NavigateUrl=&lt;span style="color: #ce0202"&gt;&amp;quot;&amp;lt;%$RouteUrl:routename=ReportRoute,reportname=products%&amp;gt;&amp;quot;&lt;/span&gt;&amp;gt;Product Report&amp;lt;/asp:HyperLink&amp;gt;&amp;lt;/li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;asp:HyperLink ID=&lt;span style="color: #ce0202"&gt;&amp;quot;hypHelp&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; NavigateUrl=&lt;span style="color: #ce0202"&gt;&amp;quot;&amp;lt;%$RouteUrl:routename=default,controller=home,action=help%&amp;gt;&amp;quot;&lt;/span&gt;&amp;gt;Help&amp;lt;/asp:HyperLink&amp;gt;&amp;lt;/li&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;/ul&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;We are done adding the common navigation to our application. 
  &lt;br /&gt;

  &lt;br /&gt;The application now uses a common theme, routing and navigation structure. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;Conclusion 
    &lt;br /&gt;&lt;/strong&gt;We have seen how to do the following through this post&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Add a WebForm page from a WebForm project to an existing ASP.NET MVC application &lt;/li&gt;

  &lt;li&gt;Use a common master page for both WebForm and MVC pages &lt;/li&gt;

  &lt;li&gt;Use routing for SEO friendly links &lt;/li&gt;

  &lt;li&gt;Use a common menu structure for both WebForm and MVC. 
    &lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The sample project is attached below. 
  &lt;br /&gt;&lt;strong&gt;Version: VS 2010 RTM 
    &lt;br /&gt;&lt;/strong&gt;Remember to change your connection string to point to your Northwind database&lt;/p&gt;

&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:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:d52bcb32-be56-4bf8-bf7c-73092c486d3a" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/NorthwindSalesMVCWebform_120F790D.zip" target="_self" onClick="javascript: pageTracker._trackPageview('NorthwindSalesMVCWebform.zip');"&gt;NorthwindSalesMVCWebform.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;-
  &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7479048" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/MVC/default.aspx">MVC</category></item><item><title>Creating an ASP.NET report using Visual Studio 2010 - Part 3</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-interactive-report-using-visual-studio-2010-part-3.aspx</link><pubDate>Mon, 10 May 2010 04:14:58 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7477105</guid><dc:creator>rajbk</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7477105</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-interactive-report-using-visual-studio-2010-part-3.aspx#comments</comments><description>We continue building our report in this three part series.   &lt;br /&gt;  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx" target="_blank"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 1&lt;/a&gt;   &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-report-using-visual-studio-2010-part-2.aspx" target="_blank"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 2&lt;/a&gt;   &lt;br /&gt;  &lt;br /&gt;&lt;strong&gt;Adding the ReportViewer control and filter drop downs.    &lt;br /&gt;    &lt;br /&gt;&lt;/strong&gt;Open the source code for index.aspx and add a ScriptManager control. This control is required for the ReportViewer control. Add a DropDownList for the categories and suppliers. Add the ReportViewer control. The markup after these steps is shown below.   &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;div&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;asp:ScriptManager ID=&lt;span style="color: #ce0202"&gt;&amp;quot;smScriptManager&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;/asp:ScriptManager&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;div id=&lt;span style="color: #ce0202"&gt;&amp;quot;searchFilter&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Filter by: Category :&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;asp:DropDownList ID=&lt;span style="color: #ce0202"&gt;&amp;quot;ddlCategories&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        and Supplier :&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;asp:DropDownList ID=&lt;span style="color: #ce0202"&gt;&amp;quot;ddlSuppliers&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;rsweb:ReportViewer ID=&lt;span style="color: #ce0202"&gt;&amp;quot;rvProducts&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #ce0202"&gt;&amp;quot;server&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;/rsweb:ReportViewer&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The design view for index.aspx is shown below. The dropdowns will display the categories and suppliers in the database. The report will be filtered by the selections in the dropdowns. You will see how to do this in the next steps. 
  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_618D04AA.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://weblogs.asp.net/blogs/rajbk/image_thumb_2C144285.png" width="417" height="201" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;Attaching the RDLC to the ReportViewer control by clicking on the top right of the control, going to Report Viewer tasks and selecting Products.rdlc.&amp;#160;&amp;#160; &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_6767A843.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://weblogs.asp.net/blogs/rajbk/image_thumb_786BD626.png" width="684" height="115" /&gt;&lt;/a&gt; 

  &lt;br /&gt;Resize the ReportViewer control by dragging at the bottom right corner. I set mine to &lt;font size="3" face="Consolas"&gt;800px x 500px&lt;/font&gt;. You can set this value in source view also. &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&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://weblogs.asp.net/blogs/rajbk/image125_7793703C.png" width="568" height="207" /&gt; 

  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;Defining the data sources.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;We will now define the Data Source used to populate the report. Go back to the “ReportViewer Tasks” and select “Choose Data Sources” 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image128_3E106045.png" width="311" height="165" /&gt; 

  &lt;br /&gt;Select a “New data source..” 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image131_1D892093.png" width="400" height="147" /&gt; &lt;/p&gt;

&lt;p&gt;Select “Object” and name your Data Source ID “odsProducts” 
  &lt;br /&gt;

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image134_43EB03DE.png" width="756" height="564" /&gt;&amp;#160; &lt;br /&gt;In the next screen, choose “ProductRepository” as your business object. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image137_0D99DBCF.png" width="610" height="100" /&gt; 

  &lt;br /&gt;Choose “GetProductsProjected” in the next screen. 

  &lt;br /&gt;

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image140_0D2DA8DA.png" width="536" height="286" /&gt;&amp;#160; &lt;br /&gt;The method requires a SupplierID and CategoryID. We will have the data source use the selected values of the drop down lists we defined earlier. Set the parameter source to be of type “Control” and set the ControlIDs to be &lt;u&gt;ddlSuppliers and ddlCategories respectively&lt;/u&gt;. Your screen will look like this: 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image143_617CDEDD.png" width="710" height="255" /&gt; 

  &lt;br /&gt;We are now going to define the data source for our drop downs. Select the ddlCategory drop down and pick “Choose Data Source”.&lt;/p&gt;

&lt;p&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://weblogs.asp.net/blogs/rajbk/image149_72ED3FB5.png" width="467" height="119" /&gt; 

  &lt;br /&gt;Pick “Object” and give it an id “odsCategories” 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image152_194F2301.png" width="388" height="277" /&gt;&amp;#160; &lt;br /&gt;In the next screen, choose “ProductRepository” 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image155_23A04761.png" width="590" height="67" /&gt; 

  &lt;br /&gt;Select the GetCategories() method in the next screen. 

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image158_6A1D3769.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://weblogs.asp.net/blogs/rajbk/image158_thumb_02ACD4BA.png" width="419" height="108" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;Select “CategoryName” and “CategoryID” in the next screen. We are done defining the data source for the Category drop down. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image161_302DF47D.png" width="299" height="180" /&gt; 

  &lt;br /&gt;Perform the same steps for the Suppliers drop down.&lt;/p&gt;

&lt;p&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://weblogs.asp.net/blogs/rajbk/image164_61B96212.png" width="319" height="72" /&gt; 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image167_5D42E14B.png" width="412" height="110" /&gt; 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image170_47E52BE3.png" width="294" height="174" /&gt;&amp;#160; &lt;br /&gt;Select &lt;u&gt;each&lt;/u&gt; dropdown and set the AppendDataBoundItems to true and AutoPostback to true. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image173_3C4F6EA4.png" width="347" height="84" /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;The AppendDataBoundItems is needed because we are going to insert an “All“ list item with a value of &lt;u&gt;empty&lt;/u&gt;. This will be the first item in each drop down list. Go to each drop down and add this list item markup as shown below. 

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_6008963E.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://weblogs.asp.net/blogs/rajbk/image_thumb_33EB994D.png" width="711" height="72" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Double click on each drop down in the designer and add the following code in the code behind. This along with the “Autopostback= true” attribute refreshes the report anytime the selection in the drop down is changed. &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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;protected&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;void&lt;/span&gt; ddlCategories_SelectedIndexChanged(&lt;span style="color: #006699; font-weight: bold !important"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    rvProducts.LocalReport.Refresh();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;protected&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;void&lt;/span&gt; ddlSuppliers_SelectedIndexChanged(&lt;span style="color: #006699; font-weight: bold !important"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    rvProducts.LocalReport.Refresh();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Compile your report and run the page. You should see the report rendered. Note that the tool bar in the ReportViewer control gives you a couple of options including the ability to export the data to Excel, PDF or word.&lt;/p&gt;

&lt;p&gt;&amp;#160;&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://weblogs.asp.net/blogs/rajbk/image_1A17631E.png" width="740" height="123" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Through this three part series, we did the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Created a data layer for use by our RDLC. &lt;/li&gt;

  &lt;li&gt;Created an RDLC using the report wizard and define a dataset for the report. &lt;/li&gt;

  &lt;li&gt;Used the report design surface to design our report including adding a chart. &lt;/li&gt;

  &lt;li&gt;Used the ReportViewer control to attach the RDLC. &lt;/li&gt;

  &lt;li&gt;Connected our ReportWiewer to a data source and take parameter values from the drop downlists. &lt;/li&gt;

  &lt;li&gt;Used AutoPostBack to refresh the reports when the dropdown selection was changed. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;RDLCs allow you to create interactive reports including drill downs and grouping. For even more advanced reports you can use &lt;a href="http://www.microsoft.com/sqlserver/2008/en/us/reporting.aspx" target="_blank"&gt;Microsoft® SQL Server™ Reporting Services&lt;/a&gt; with RDLs. With RDLs, the report is rendered on the report server instead of the web server. Another nice thing about RDLs is that you can define a parameter list for the report and it gets rendered automatically for you. RDLCs and RDLs both have their advantages and its best to compare them and choose the right one for your requirements. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;Download VS2010 RTM Sample project&lt;/strong&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:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:508a5736-d5c3-4b15-8353-d9ccc5abe304" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/NorthwindReports_4BA2D0B3.zip" target="_self" onClick="javascript: pageTracker._trackPageview('NorthwindReports.zip');"&gt;NorthwindReports.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;strong&gt;Related posts
    &lt;br /&gt;&lt;/strong&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2006/03/02/How-to-render-client-report-definition-files-_28002E00_rdlc_2900_-directly-to-the-Response-stream-without-preview.aspx"&gt;How to render client report definition files (.rdlc) directly to the Response stream without preview&lt;/a&gt;&amp;#160; &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx"&gt;Rendering an RDLC directly to the Response stream in ASP.NET MVC&lt;/a&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Alfred Borden: &lt;em&gt;Are you watching closely?&lt;/em&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7477105" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Data/default.aspx">Data</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Reports/default.aspx">Reports</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>Creating an ASP.NET report using Visual Studio 2010 - Part 2</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-report-using-visual-studio-2010-part-2.aspx</link><pubDate>Mon, 10 May 2010 04:14:13 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7477104</guid><dc:creator>rajbk</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7477104</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-report-using-visual-studio-2010-part-2.aspx#comments</comments><description>&lt;div&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;!--CRLF--&gt;&lt;/div&gt; &lt;/div&gt;  &lt;div&gt;We continue building our report in this three part series.    &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx" target="_blank"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 1&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-interactive-report-using-visual-studio-2010-part-3.aspx" target="_blank"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 3&lt;/a&gt;&lt;/div&gt;  &lt;div&gt;   &lt;br /&gt;&lt;strong&gt;Creating the Client Report Definition file (RDLC)      &lt;br /&gt;      &lt;br /&gt;&lt;/strong&gt;Add a folder called “RDLC”. This will hold our RDLC report.     &lt;br /&gt;    &lt;br /&gt;&lt;strong&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://weblogs.asp.net/blogs/rajbk/image_74B65954.png" width="135" height="93" /&gt;&lt;/strong&gt;&amp;#160; &lt;br /&gt;Right click on the RDLC folder, select “Add new item..” and add an “RDLC” name of “Products”. We will use the “Report Wizard” to walk us through the steps of creating the RDLC.     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_5F58A3EC.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://weblogs.asp.net/blogs/rajbk/image_thumb_5DA7D818.png" width="804" height="454" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;In the next dialog, give the dataset a name called “ProductDataSet”. Change the data source to “NorthwindReports.DAL” and select “ProductRepository(GetProductsProjected)”.     &lt;br /&gt;&lt;/div&gt;  &lt;div&gt;The “Data Source” may show up empty. To get it populated, make sure your project is compiled and there is an index.aspx file in the root folder. This may be a bug. &lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;The fields that are returned from the method are shown on the right. Click next.    &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_5139B4EF.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://weblogs.asp.net/blogs/rajbk/image_thumb_623DE2D2.png" width="605" height="434" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;Drag and drop the ProductName, CategoryName, UnitPrice and Discontinued into the Values container. Note that you can create much more complex grouping using this UI. Click Next. &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image56_3620E5E1.png" width="605" height="434" /&gt;&amp;#160; &lt;br /&gt;Most of the selections on this screen are grayed out because we did not choose a grouping in the previous screen. Click next.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image59_6020E409.png" width="605" height="434" /&gt;     &lt;br /&gt;Choose a style for your report. Click next.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image62_7EF757E7.png" width="605" height="434" /&gt;     &lt;br /&gt;The report graphic design surface is now visible. Right click on the report and add a page header and page footer.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image68_72F567B3.png" width="420" height="154" /&gt;     &lt;br /&gt;With the report design surface active, drag and drop a TextBox from the tool box to the page header. Drag one more textbox to the page header. We will use the text boxes to add some header text as shown in the next figure. &lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image74_76938290.png" width="715" height="220" /&gt;     &lt;br /&gt;You can change the font size and other properties of the textboxes using the formatting tool bar (marked in red). You can also resize the columns by moving your cursor in between columns and dragging.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image83_5CBF4C61.png" width="832" height="252" /&gt;     &lt;br /&gt;&lt;strong&gt;     &lt;br /&gt;Adding Expressions &lt;/strong&gt;    &lt;br /&gt;    &lt;br /&gt;Add two more text boxes to the page footer. We will use these to add the time the report was generated and page numbers. Right click on the first textbox in the page footer and select “Expression”.     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image86_22D00975.png" width="686" height="256" /&gt;     &lt;br /&gt;Add the following expression for the print date (note the = sign at the left of the expression in the dialog below)     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image89_30361C7B.png" width="554" height="504" /&gt; &lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ce0202"&gt;&amp;quot;© Northwind Traders &amp;quot;&lt;/span&gt; &amp;amp; Format(Now(),&lt;span style="color: #ce0202"&gt;&amp;quot;MM/dd/yyyy hh:mm tt&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
Right click on the second text box and add the following for the page count.&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;Globals.PageNumber &amp;amp; &lt;span style="color: #ce0202"&gt;&amp;quot; of &amp;quot;&lt;/span&gt; &amp;amp; Globals.TotalPages&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;Formatting the page footer is complete. &lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;We are now going to format the “Unit Price” column so it displays the number in currency format.&amp;#160; Right click on the [UnitPrice] column (&lt;u&gt;not header&lt;/u&gt;) and select “Text Box Properties..”&lt;/div&gt;

&lt;p&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://weblogs.asp.net/blogs/rajbk/image196_562BCCD1.png" width="281" height="273" /&gt; 

  &lt;br /&gt;Under “Number”, select “Currency”. Hit OK. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image199_07B73A67.png" width="569" height="348" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding a chart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the design surface active, go to the toolbox and drag and drop a chart control. You will need to move the product list table down first to make space for the chart contorl. The document can also be resized by dragging on the corner or at the page header/footer separator.&lt;/p&gt;

&lt;p&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://weblogs.asp.net/blogs/rajbk/image96_4DC7F77A.png" width="347" height="355" /&gt; 

  &lt;br /&gt;In the next dialog, pick the first chart type. This can be changed later if needed. Click OK. The chart gets added to the design surface. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image99_26217B50.png" width="352" height="486" /&gt;&amp;#160; &lt;br /&gt;Click on the blue bars in the chart (not legend). This will bring up drop locations for dropping the fields. Drag and drop the UnitPrice and CategoryName into the top (y axis) and bottom (x axis) as shown below. This will give us the total unit prices for a given category. That is the best I could come up with as far as what report to render, sorry :-) Delete the legend area to get more screen estate. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image102_5D878C7E.png" width="747" height="423" /&gt; 

  &lt;br /&gt;Resize the chart to your liking. Change the header, x axis and y axis text by double clicking on those areas. 

  &lt;br /&gt;

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image106_0A304658.png" width="654" height="232" /&gt; 

  &lt;br /&gt;We made it this far. Let’s impress the client by adding a gradient to the bar graph :-) Right click on the blue bar and select “Series properties”. 

  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image110_1BA0A730.png" width="334" height="209" /&gt;&lt;/p&gt;

&lt;p&gt;Under “Fill”, add a color and secondary color and select the Gradient style. 
  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_100AE9F1.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://weblogs.asp.net/blogs/rajbk/image_thumb_68646DC6.png" width="353" height="391" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are done designing our report. In the next section you will see how to add the report to the report viewer control, bind to the data and make it refresh when the filter criteria are changed. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-interactive-report-using-visual-studio-2010-part-3.aspx" target="_blank"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other Posts&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/12/adding-a-hyperlink-in-a-client-report-definition-file-rdlc.aspx"&gt;Adding a hyperlink in a client report definition file (RDLC)&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx" target="_blank"&gt;Rendering an RDLC directly to the Response stream in ASP.NET MVC&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx" target="_blank"&gt;ASP.NET MVC Paging/Sorting/Filtering using the MVCContrib Grid and Pager&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/27/localization-in-asp-net-mvc-2-using-modelmetadata.aspx"&gt;Localization in ASP.NET MVC 2 using ModelMetadata&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/21/setting-up-visual-studio-2010-to-step-into-microsoft-net-source-code.aspx"&gt;Setting up Visual Studio 2010 to step into Microsoft .NET Source Code&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx"&gt;Running ASP.NET Webforms and ASP.NET MVC side by side&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx"&gt;Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7477104" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/SQL/default.aspx">SQL</category></item><item><title>Creating an ASP.NET report using Visual Studio 2010 - Part 1</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx</link><pubDate>Mon, 10 May 2010 04:13:41 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7477103</guid><dc:creator>rajbk</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7477103</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx#comments</comments><description>&lt;p&gt;This tutorial walks you through creating an ASP.NET report based on the Northwind sample database. It shows how to add a client report definition file (RDLC), create a dataset for the RDLC, define queries using LINQ to Entities, design the report and add a ReportViewer web control to render the report in a ASP.NET web page. The report will have a chart control. The result can be filtered by two drop downs at the top..    &lt;br /&gt;    &lt;br /&gt;At the end of the walkthrough, you should have a UI like the following.&amp;#160; As shown, there is a product list report with an embedded chart. The chart shows the sum of Unit price for a given category. It is possible to filter the results by Category and Supplier. The drop downs auto post back when the selection is changed.&amp;#160; This demo uses &lt;strong&gt;Visual Studio 2010 RTM.&lt;/strong&gt;     &lt;br /&gt;    &lt;br /&gt;This post is split into three parts. &lt;strong&gt;The last part has the sample code attached.&lt;/strong&gt;     &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-report-using-visual-studio-2010-part-2.aspx"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 2&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-interactive-report-using-visual-studio-2010-part-3.aspx"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 3&lt;/a&gt;     &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_103F6F57.png" width="813" height="544" /&gt;&amp;#160; &lt;br /&gt;    &lt;br /&gt;Lets start by creating a new ASP.NET empty web application called “NorthwindReports”     &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_15ADDFFB.png" width="804" height="454" /&gt;     &lt;br /&gt;&lt;strong&gt;Creating the Data Access Layer (DAL)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Add a web form called index.aspx to the root directory. You do this by right clicking on the NorthwindReports web project and selecting “Add item..”    &lt;br /&gt;.     &lt;br /&gt;Create a folder called “DAL”. We will store all our data access methods and any data transfer objects in here.&lt;/p&gt;  &lt;p&gt;&amp;#160;&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://weblogs.asp.net/blogs/rajbk/image_1F269E71.png" width="247" height="180" /&gt; &lt;/p&gt;  &lt;p&gt;Right click on the DAL folder and add a ADO.NET Entity data model called Northwind. &lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_5A7A042F.png" width="804" height="454" /&gt; &lt;/p&gt;  &lt;p&gt;Select “Generate from database” and click Next.&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_6B11FF1D.png" width="627" height="558" /&gt;     &lt;br /&gt;Create a connection to your database containing the Northwind sample database and click Next.&lt;/p&gt;  &lt;p&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://weblogs.asp.net/blogs/rajbk/image_70ECA2B6.png" width="627" height="558" /&gt;&amp;#160; &lt;br /&gt;From the table list, select Categories, Products and Suppliers and click next.     &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_4F8CFD1A.png" width="627" height="573" /&gt;     &lt;br /&gt;Our Entity data model gets created and looks like this:     &lt;br /&gt;    &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_193BD50B.png" width="639" height="359" /&gt;&amp;#160;&amp;#160; &lt;br /&gt;&lt;strong&gt;Adding data transfer objects      &lt;br /&gt;&lt;/strong&gt;    &lt;br /&gt;Right click on the DAL folder and add a ProductViewModel. Add the following code. This class contains properties we need to render our report. &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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; ProductViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? ProductID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; ProductName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; System.Nullable&amp;lt;&lt;span style="color: #006699; font-weight: bold !important"&gt;decimal&lt;/span&gt;&amp;gt; UnitPrice { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; CategoryName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? CategoryID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? SupplierID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;Add a SupplierViewModel class. This will be used to render the supplier DropDownlist. 

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; SupplierViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; CompanyName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt; SupplierID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;br /&gt;Add a CategoryViewModel class. 

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; CategoryViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; CategoryName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt; CategoryID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Create an IProductRepository interface. This will contain the signatures of all the methods we need when accessing the entity model.&amp;#160; This step is not needed but follows the &lt;a href="http://msdn.microsoft.com/en-us/library/ff649690.aspx" target="_blank"&gt;repository pattern&lt;/a&gt;.&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;interface&lt;/span&gt; IProductRepository&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        IQueryable&amp;lt;Product&amp;gt; GetProducts();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        IQueryable&amp;lt;ProductViewModel&amp;gt; GetProductsProjected(&lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? supplierID, &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? categoryID);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        IQueryable&amp;lt;SupplierViewModel&amp;gt; GetSuppliers();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        IQueryable&amp;lt;CategoryViewModel&amp;gt; GetCategories();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Create a ProductRepository class that implements the IProductReposity above. The methods available in this class are as follows: 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;GetProducts – returns an IQueryable of all products. &lt;/li&gt;

  &lt;li&gt;GetProductsProjected – returns an IQueryable of ProductViewModel. The method filters all the products based on SupplierId and CategoryId if any. It then projects the result into the ProductViewModel. &lt;/li&gt;

  &lt;li&gt;GetSuppliers() – returns an IQueryable of all suppliers projected into a SupplierViewModel &lt;/li&gt;

  &lt;li&gt;GetCategories() – returns an IQueryable of all categories projected into a CategoryViewModel&amp;#160; &lt;/li&gt;
&lt;/ul&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; ProductRepository : IProductRepository&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// IQueryable of all Products&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; IQueryable&amp;lt;Product&amp;gt; GetProducts()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        var dataContext = &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; NorthwindEntities();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        var products = from p &lt;span style="color: #006699; font-weight: bold !important"&gt;in&lt;/span&gt; dataContext.Products&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                       select p;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; products;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// IQueryable of Projects projected &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// into the ProductViewModel class&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; IQueryable&amp;lt;ProductViewModel&amp;gt; GetProductsProjected(&lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? supplierID, &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? categoryID)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        var projectedProducts = from p &lt;span style="color: #006699; font-weight: bold !important"&gt;in&lt;/span&gt; GetProducts()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                select &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; ProductViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                    ProductID = p.ProductID,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                    ProductName = p.ProductName,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                    UnitPrice = p.UnitPrice,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                    CategoryName = p.Category.CategoryName,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                    CategoryID = p.CategoryID,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                    SupplierID = p.SupplierID,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                    Discontinued = p.Discontinued&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// Filter on SupplierID &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (supplierID.HasValue)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            projectedProducts = projectedProducts.Where(a =&amp;gt; a.SupplierID == supplierID);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// Filter on CategoryID &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (categoryID.HasValue)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            projectedProducts = projectedProducts.Where(a =&amp;gt; a.CategoryID == categoryID);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; projectedProducts;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; IQueryable&amp;lt;SupplierViewModel&amp;gt; GetSuppliers()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        var dataContext = &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; NorthwindEntities();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        var suppliers = from s &lt;span style="color: #006699; font-weight: bold !important"&gt;in&lt;/span&gt; dataContext.Suppliers&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        select &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; SupplierViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                            SupplierID = s.SupplierID,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                            CompanyName = s.CompanyName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; suppliers;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; IQueryable&amp;lt;CategoryViewModel&amp;gt; GetCategories()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        var dataContext = &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; NorthwindEntities();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        var categories = from c &lt;span style="color: #006699; font-weight: bold !important"&gt;in&lt;/span&gt; dataContext.Categories&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                         select &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; CategoryViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                             CategoryID = c.CategoryID,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                             CategoryName = c.CategoryName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                         };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; categories;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;Your solution explorer should look like the following. 

&lt;br /&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://weblogs.asp.net/blogs/rajbk/image_4D03CB5C.png" width="262" height="324" /&gt; 

&lt;p&gt;&lt;strong&gt;Build your project and make sure you don’t get any errors.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the next part, we will see how to create the client report definition file using the Report Wizard.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-a-asp-net-report-using-visual-studio-2010-part-2.aspx"&gt;Creating an ASP.NET report using Visual Studio 2010 - Part 2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other Posts&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/12/adding-a-hyperlink-in-a-client-report-definition-file-rdlc.aspx"&gt;Adding a hyperlink in a client report definition file (RDLC)&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx" target="_blank"&gt;Rendering an RDLC directly to the Response stream in ASP.NET MVC&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx" target="_blank"&gt;ASP.NET MVC Paging/Sorting/Filtering using the MVCContrib Grid and Pager&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/27/localization-in-asp-net-mvc-2-using-modelmetadata.aspx"&gt;Localization in ASP.NET MVC 2 using ModelMetadata&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/21/setting-up-visual-studio-2010-to-step-into-microsoft-net-source-code.aspx"&gt;Setting up Visual Studio 2010 to step into Microsoft .NET Source Code&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx"&gt;Running ASP.NET Webforms and ASP.NET MVC side by side&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/15/pre-filtering-and-shaping-odata-feeds-using-wcf-data-services-and-the-entity-framework-part-1.aspx"&gt;Pre-filtering and shaping OData feeds using WCF Data Services and the Entity Framework&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7477103" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/UX/default.aspx">UX</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>ASP.NET MVC Paging/Sorting/Filtering using the MVCContrib Grid and Pager</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx</link><pubDate>Sat, 08 May 2010 15:30:41 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7475159</guid><dc:creator>rajbk</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7475159</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx#comments</comments><description>&lt;p&gt;This post walks you through creating a UI for paging, sorting and filtering a list of data items. It makes use of the excellent MVCContrib Grid and Pager Html UI helpers. A sample project is attached at the bottom.&lt;/p&gt;  &lt;p&gt;Our UI will eventually look like this. The application will make use of the Northwind database.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_193D3204.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://weblogs.asp.net/blogs/rajbk/image_thumb_28FCC708.png" width="740" height="497" /&gt;&lt;/a&gt;     &lt;br /&gt;The top portion of the page has a filter area region. The filter region is enclosed in a form tag. The select lists are wired up with jQuery to &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/06/autopostback-select-lists-in-asp-net-mvc-using-jquery.aspx" target="_blank"&gt;auto post back&lt;/a&gt; the form.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;The page has a pager region at the top and bottom of the product list. &lt;/p&gt;  &lt;p&gt;The product list has a link to display more details about a given product. The column headings are clickable for sorting and an icon shows the sort direction. &lt;/p&gt; A request with this UI will look similar to this : &lt;strong&gt;/Products?productName=chai&amp;amp;supplierId=29&amp;amp;categoryId=4&amp;amp;Column=CategoryName&amp;amp;Direction=Ascending. &lt;/strong&gt;This request translates into a request for products that contain the text “chai” and supplierid=29 and categoryid=29. The results are sorted in ascending order by categoryname.   &lt;br /&gt;  &lt;br /&gt;&lt;strong&gt;Strongly Typed View Models&lt;/strong&gt;   &lt;br /&gt;  &lt;br /&gt;The views are written to expect strongly typed objects. We suffix these strongly typed objects with ViewModel and will be used for passing data down to the view.&amp;#160; &lt;br /&gt;  &lt;br /&gt;The following listing shows the ProductViewModel. This class will be used to hold information about a Product. We use attributes to specify if the property should be hidden and what its heading in the table should be. This metadata will be used by the MvcContrib Grid to render the table. Some of the properties are hidden from the UI ([ScaffoldColumn(false)) but are needed because we will be using those for filtering when writing our LINQ query.   &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: consolas, &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: consolas, &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: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;class&lt;/span&gt; ProductViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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;    [ScaffoldColumn(&lt;span style="color: #900"&gt;false&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;int&lt;/span&gt;? ProductID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;string&lt;/span&gt; ProductName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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;    [DisplayName(&lt;span style="color: #900"&gt;&amp;quot;Unit Price&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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;    [DisplayFormat(DataFormatString = &lt;span style="color: #900"&gt;&amp;quot;{0:c}&amp;quot;&lt;/span&gt;)] &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; System.Nullable&amp;lt;&lt;span style="color: #900"&gt;decimal&lt;/span&gt;&amp;gt; UnitPrice { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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;    [DisplayName(&lt;span style="color: #900"&gt;&amp;quot;Category Name&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;string&lt;/span&gt; CategoryName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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;    [ScaffoldColumn(&lt;span style="color: #900"&gt;false&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;int&lt;/span&gt;? CategoryID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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;    [ScaffoldColumn(&lt;span style="color: #900"&gt;false&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;int&lt;/span&gt;? SupplierID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The following diagram shows the rest of the key ViewModels in our design.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_35F6A719.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://weblogs.asp.net/blogs/rajbk/image_thumb_41ABEE4B.png" width="666" height="423" /&gt;&lt;/a&gt; 

  &lt;br /&gt;We have a container class called ProductListContainerViewModel which has nested classes. 

  &lt;br /&gt;

  &lt;br /&gt;The ProductPagedList is of type IPagination&amp;lt;ProductViewModel&amp;gt;. The MvcContrib expects the IPagination&amp;lt;T&amp;gt; interface to determine the page number and page size of the collection we are working with. You convert any IEnumerable&amp;lt;T&amp;gt; into an IPagination&amp;lt;T&amp;gt; by calling the AsPagination extension method in the MvcContrib library. It also creates a paged set of type ProductViewModel. 

  &lt;br /&gt;

  &lt;br /&gt;The ProductFilterViewModel class holds information about the different select lists and the ProductName being searched on. It also holds the state of any previously selected item in the lists and the previous search criteria (you will recall that this type of state information was stored in Viewstate when working with WebForms). With MVC there is no default state storage and so all state has to be fetched and passed back to the view. &lt;/p&gt;

&lt;p&gt;The GridSortOptions is a type defined in the MvcContrib library and is used by the Grid to determine the current column being sorted on and the current sort direction.&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;The following shows the view and partial views used to render our UI. The Index view expects a Model of type ProductListContainerViewModel.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_596325B1.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://weblogs.asp.net/blogs/rajbk/image_thumb_6922BAB5.png" width="446" height="555" /&gt;&lt;/a&gt; 

  &lt;br /&gt;Index.aspx code:&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;%Html.RenderPartial(&lt;span style="color: #ce0202"&gt;&amp;quot;SearchFilters&amp;quot;&lt;/span&gt;, Model.ProductFilterViewModel); %&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;% Html.RenderPartial(&lt;span style="color: #ce0202"&gt;&amp;quot;Pager&amp;quot;&lt;/span&gt;, Model.ProductPagedList); %&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;% Html.RenderPartial(&lt;span style="color: #ce0202"&gt;&amp;quot;SearchResults&amp;quot;&lt;/span&gt;, Model); %&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;% Html.RenderPartial(&lt;span style="color: #ce0202"&gt;&amp;quot;Pager&amp;quot;&lt;/span&gt;, Model.ProductPagedList); %&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The View contains a partial view “SearchFilters” and passes it the ProductViewFilterContainer. The SearchFilter uses this Model to render all the search lists and textbox. 
  &lt;br /&gt;

  &lt;br /&gt;The partial view “Pager” uses the ProductPageList which implements the interface IPagination. The “Pager” view contains the MvcContrib Pager helper used to render the paging information. This view is repeated twice since we want the pager UI to be available at the top and bottom of the product list. The Pager partial view is located in the Shared directory so that it can be reused across Views. 

  &lt;br /&gt;

  &lt;br /&gt;The partial view “SearchResults” uses the ProductListContainer model. This partial view contains the MvcContrib Grid which needs both the ProdctPagedList &lt;em&gt;and &lt;/em&gt;GridSortOptions to render itself. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;The Controller Action&amp;#160; &lt;br /&gt;&lt;/strong&gt;The application receives this GET request and maps it to the Index method of the ProductController. 

  &lt;br /&gt;Within the action we create an IQueryable&amp;lt;ProductViewModel&amp;gt; by calling the GetProductsProjected() method.&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// This method takes in a filter list, paging/sort options and applies&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// them to an IQueryable of type ProductViewModel&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;returns&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// The return object is a container that holds the sorted/paged list,&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// state for the fiters and state about the current sorted column&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/returns&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; ActionResult Index(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; productName, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? supplierID, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? categoryID, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    GridSortOptions gridSortOptions, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt;? page)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    var productList = productRepository.GetProductsProjected();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// Set default sort column&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (&lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt;.IsNullOrWhiteSpace(gridSortOptions.Column))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        gridSortOptions.Column = &lt;span style="color: #ce0202"&gt;&amp;quot;ProductID&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// Filter on SupplierID &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (supplierID.HasValue)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        productList.Where(a =&amp;gt; a.SupplierID == supplierID);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// Filter on CategoryID &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (categoryID.HasValue)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        productList = productList.Where(a =&amp;gt; a.CategoryID == categoryID);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// Filter on ProductName&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (!&lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt;.IsNullOrWhiteSpace(productName))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        productList = productList.Where(a =&amp;gt; a.ProductName.Contains(productName));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// Create all filter data and set current values if any&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// These values will be used to set the state of the select list and textbox&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// by sending it back to the view.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    var productFilterViewModel = &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; ProductFilterViewModel();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    productFilterViewModel.SelectedCategoryID = categoryID ?? -1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    productFilterViewModel.SelectedSupplierID = supplierID ?? -1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    productFilterViewModel.Fill();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// Order and page the product list&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    var productPagedList = productList&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           .OrderBy(gridSortOptions.Column, gridSortOptions.Direction)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           .AsPagination(page ?? 1, 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: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    var productListContainer = &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; ProductListContainerViewModel&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        ProductPagedList = productPagedList,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        ProductFilterViewModel = productFilterViewModel,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        GridSortOptions = gridSortOptions&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; View(productListContainer);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The supplier, category and productname filters are applied to this IQueryable if any are present in the request. The ProductPagedList class is created by applying a sort order and calling the AsPagination method. Finally, the ProductListContainerViewModel class is created and returned to the view. 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;You have seen how to use strongly typed views with the MvcContrib Grid and Pager to render a clean lightweight UI with strongly typed views. You also saw how to use partial views to get data from the strongly typed model passed to it from the parent view. The code also shows you how to use jQuery to &lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/06/autopostback-select-lists-in-asp-net-mvc-using-jquery.aspx" target="_blank"&gt;auto post back&lt;/a&gt;. 

  &lt;br /&gt;

  &lt;br /&gt;The nice thing about the MvcContrib Pager and Grid is that it is aware of the original query string and keeps it intact when creating links for sorting and paging.&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;The sample is attached below. Don’t forget to change your connection string to point to the server containing the Northwind database. &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:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:db3ca5c8-7ae0-4342-bc51-f5e8da059ae2" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/NorthwindSales_MvcContrib_60BEE55E.zip" target="_self" onClick="javascript: pageTracker._trackPageview('NorthwindSales_MvcContrib.zip');"&gt;NorthwindSales_MvcContrib.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;
  &lt;br /&gt;Related Posts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx" target="_blank"&gt;Creating an ASP.NET report using Visual Studio 2010&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx" target="_blank"&gt;Running ASP.NET Webforms and ASP.NET MVC side by side&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/05/03/actionresult-types-in-mvc2.aspx" target="_blank"&gt;ActionResult types in MVC 2&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/18/code-snippets-for-asp-net-mvc2-in-vs-2010.aspx" target="_blank"&gt;Code snippets for ASP.NET MVC2 in VS 2010&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/rajbk/archive/2010/04/01/securing-an-asp-net-mvc-2-application.aspx" target="_blank"&gt;Securing an ASP.NET MVC 2 Application&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;My name is Kobayashi. I work for Keyser Soze.&lt;/em&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7475159" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>Autopostback select lists in ASP.NET MVC using jQuery</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/06/autopostback-select-lists-in-asp-net-mvc-using-jquery.aspx</link><pubDate>Thu, 06 May 2010 16:18:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7472763</guid><dc:creator>rajbk</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7472763</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/06/autopostback-select-lists-in-asp-net-mvc-using-jquery.aspx#comments</comments><description>&lt;p&gt;This tiny snippet of code show you how to have your select lists autopostback its containing form when the selected value changes.    &lt;br /&gt;    &lt;br /&gt;When the &lt;a href="http://api.jquery.com/ready/"&gt;DOM is fully loaded&lt;/a&gt;, we get all select nodes that have an attribute of “data-autopostback” with a value of “true”.     &lt;br /&gt;    &lt;br /&gt;We wire up the “&lt;a href="http://api.jquery.com/change/"&gt;change&lt;/a&gt;” JavaScript event to all these select nodes. This event is fired as soon as the user changes their selection with the mouse.&amp;#160; &lt;br /&gt;    &lt;br /&gt;When the event is fired, we find the &lt;a href="http://api.jquery.com/closest/"&gt;closest&lt;/a&gt; form tag for the select node that raised the event and submit the form.&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: consolas, &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: consolas, &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: consolas, &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;$(document).ready(function () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;&amp;quot;select:[data-autopostback=true]&amp;quot;&lt;/span&gt;).change(function () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;this&lt;/span&gt;).closest(&lt;span style="color: #900"&gt;&amp;quot;form&amp;quot;&lt;/span&gt;).submit();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;});&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;A select tag with autopostback enabled will look like this 
  &lt;br /&gt;&lt;em&gt;&lt;/em&gt;&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: consolas, &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: consolas, &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: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;select&lt;/span&gt; &lt;span style="color: #900"&gt;id&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;selCategory&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;name&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;Category&amp;quot;&lt;/span&gt; &lt;span style="color: #900"&gt;data-autopostback&lt;/span&gt;&lt;span style="color: #900"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt; &lt;span style="color: #900"&gt;value&lt;/span&gt;&lt;span style="color: #900"&gt;='1'&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt;Electronics&lt;span style="color: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt; &lt;span style="color: #900"&gt;value&lt;/span&gt;&lt;span style="color: #900"&gt;='2'&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt;Books&lt;span style="color: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;option&lt;/span&gt;&lt;span style="color: #900"&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; font-family: consolas, &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: #900"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;select&lt;/span&gt;&lt;span style="color: #900"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;br /&gt;The reason I am using “data-&amp;quot; suffix in the attribute is to be &lt;a href="http://dev.w3.org/html5/spec/dom.html#embedding-custom-non-visible-data"&gt;HTML5 Compliant&lt;/a&gt;. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;em&gt;A custom data attribute is an attribute in no namespace whose name starts with the string &amp;quot;data-&amp;quot;, has at least one character after the hyphen, is XML-compatible, and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z). 
    &lt;br /&gt;&lt;/em&gt;&lt;/p&gt;
The snippet can be used with any HTML page. 

&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7472763" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/MVC/default.aspx">MVC</category></item><item><title>A basic T4 template for generating Model Metadata in ASP.NET MVC2</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/04/a-basic-t4-template-for-generating-model-metadata-in-asp-net-mvc2.aspx</link><pubDate>Tue, 04 May 2010 06:40:09 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7469302</guid><dc:creator>rajbk</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7469302</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/04/a-basic-t4-template-for-generating-model-metadata-in-asp-net-mvc2.aspx#comments</comments><description>&lt;p&gt;I have been learning about T4 templates recently by looking at the awesome &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/fe568da5-aa1a-4178-a2a5-48813c707a7f?SRC=VSIDE" target="_blank"&gt;ADO.NET POCO entity generator&lt;/a&gt;. By using the POCO entity generator template as a base, I created a T4 template which generates metadata classes for a given Entity Data Model. This speeds coding by reducing the amount of typing required when creating view specific model and its metadata. &lt;/p&gt;  &lt;p&gt;To use this template, &lt;/p&gt;  &lt;p&gt;1) Download the template provided at the bottom. &lt;/p&gt;  &lt;p&gt;2) Set two values in the template file. The first one should point to the EDM you wish to generate metadata for. The second is used to suffix the namespace and classes that get generated. &lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; inputFile = &lt;span style="color: #ce0202"&gt;@&amp;quot;Northwind.edmx&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; suffix = &lt;span style="color: #ce0202"&gt;&amp;quot;AutoMetadata&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;br /&gt;&lt;/div&gt;
3) Add the template to your MVC 2 Visual Studio 2010 project. 

  &lt;br /&gt;

  &lt;br /&gt;Once you add it, a number of classes will get added to your project based on the number of entities you have.&amp;#160; &lt;br /&gt;

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/image_5CFFE0E8.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://weblogs.asp.net/blogs/rajbk/image_thumb_6E7041C0.png" width="287" height="275" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;One of these classes is shown below. Note that the DisplayName, Required and StringLength attributes have been added by the t4 template.&lt;/div&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//------------------------------------------------------------------------------&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// &amp;lt;auto-generated&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//     This code was generated from a template.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//     Changes to this file may cause incorrect behavior and will be lost if&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//     the code is regenerated.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// &amp;lt;/auto-generated&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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//------------------------------------------------------------------------------&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&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: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;using&lt;/span&gt; System.ComponentModel.DataAnnotations;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;namespace&lt;/span&gt; NorthwindSales.ModelsAutoMetadata&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;partial&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; CustomerAutoMetadata&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Customer ID&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [Required]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(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; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; CustomerID { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Company Name&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [Required]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(40)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; CompanyName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Contact Name&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(30)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; ContactName { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Contact Title&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(30)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; ContactTitle { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Address&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(60)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; Address { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;City&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(15)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; City { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Region&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(15)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; Region { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Postal Code&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(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: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; PostalCode { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Country&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(15)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; Country { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Phone&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(24)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; Phone { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [DisplayName(&lt;span style="color: #ce0202"&gt;&amp;quot;Fax&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        [StringLength(24)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;string&lt;/span&gt; Fax { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The following shows how the generated class can be used from your project by creating a partial class with the entity name and setting the MetadataType attribute. Note that any &lt;a href="http://blogs.msdn.com/davidebb/archive/2009/07/17/two-ways-to-use-t4-templates-support-code-vs-one-time-generation.aspx"&gt;changes&lt;/a&gt; to the auto generated files will be overwritten. You can also copy the code in the metadata class generated and create your own ViewModel class. In this case, you are responsible for keeping things in sync just like you would with any ViewModel class.&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: consolas, &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: consolas, &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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;namespace&lt;/span&gt; MyProject.Models&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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;   [MetadataType(&lt;span style="color: #900"&gt;typeof&lt;/span&gt;(CustomerAutoMetadata))]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &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: #900"&gt;public&lt;/span&gt; &lt;span style="color: #900"&gt;partial&lt;/span&gt; &lt;span style="color: #900"&gt;class&lt;/span&gt; Customer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;      &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160; &lt;br /&gt;The template is super basic&amp;#160; and does not take into account complex properties. I have tested it with the Northwind database.&amp;#160; Feel free to modify the template to suite your requirements. 

  &lt;br /&gt;&lt;/p&gt;
Standard disclaimer follows: 

&lt;br /&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Use At Your Own Risk, Works on my machine running VS 2010 RTM/ASP.NET MVC 2 
    &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:4de0623d-f63b-4e96-9872-c3898af6af55" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/rajbk/AutoMetaData_551E6047.zip" target="_self" onClick="javascript: pageTracker._trackPageview('AutoMetaData.zip');"&gt;AutoMetaData.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Mr. Incredible: Of course I have a secret identity. I don't know a single superhero who doesn't. Who wants the pressure of being super all the time?&lt;/em&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7469302" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/T4/default.aspx">T4</category></item><item><title>ActionResult types in MVC2</title><link>http://weblogs.asp.net/rajbk/archive/2010/05/03/actionresult-types-in-mvc2.aspx</link><pubDate>Mon, 03 May 2010 06:24:55 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7468223</guid><dc:creator>rajbk</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rajbk/rsscomments.aspx?PostID=7468223</wfw:commentRss><comments>http://weblogs.asp.net/rajbk/archive/2010/05/03/actionresult-types-in-mvc2.aspx#comments</comments><description>&lt;p&gt;In ASP.NET MVC, incoming browser requests gets mapped to a controller action method. The action method returns a type of ActionResult in response to the browser request. A basic example is shown 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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; HomeController : Controller&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; ActionResult Index()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; View();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Here we have an action method called Index that returns an ActionResult. Inside the method we call the View() method on the base Controller. The View() method, as you will see shortly, is a method that returns a ViewResult.&lt;/p&gt;

&lt;p&gt;The ActionResult class is the base class for different controller results. The following diagram shows the types derived from the ActionResult type.&lt;/p&gt;

&lt;p&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://weblogs.asp.net/blogs/rajbk/image_4AC54796.png" width="880" height="794" /&gt;&lt;/p&gt;

&lt;p&gt;ASP.NET has a &lt;a href="http://www.asp.net/Learn/mvc/tutorial-03-cs.aspx" target="_blank"&gt;description&lt;/a&gt; of these methods &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;ContentResult – Represents a text result. &lt;/li&gt;

  &lt;li&gt;EmptyResult – Represents no result. &lt;/li&gt;

  &lt;li&gt;FileContentResult – Represents a downloadable file (with the binary content). &lt;/li&gt;

  &lt;li&gt;FilePathResult – Represents a downloadable file (with a path). &lt;/li&gt;

  &lt;li&gt;FileStreamResult – Represents a downloadable file (with a file stream). &lt;/li&gt;

  &lt;li&gt;JavaScriptResult – Represents a JavaScript script. &lt;/li&gt;

  &lt;li&gt;JsonResult – Represents a JavaScript Object Notation result that can be used in an AJAX application. &lt;/li&gt;

  &lt;li&gt;PartialViewResult – Represents HTML and markup rendered by a partial view. &lt;/li&gt;

  &lt;li&gt;RedirectResult – Represents a redirection to a new URL. &lt;/li&gt;

  &lt;li&gt;RedirectToRouteResult – Represents a result that performs a redirection by using the specified route values dictionary. &lt;/li&gt;

  &lt;li&gt;ViewResult – Represents HTML and markup rendered by a view. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To return the types shown above, you call methods that are available in the Controller base class. Instead of creating instances of ActionResult or it’s inherited type, you call the helper methods on the Controller class and return it. A list of these methods are shown below. 
  &lt;br /&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://weblogs.asp.net/blogs/rajbk/image_7B0C1C4C.png" width="747" height="872" /&gt;&lt;strong&gt;&amp;#160; &lt;br /&gt;&lt;/strong&gt;The helper methods on the controller base class and the ActionResult type they return are listed here (ref: &lt;a title="http://msdn.microsoft.com/en-us/library/dd410269.aspx" href="http://msdn.microsoft.com/en-us/library/dd410269.aspx"&gt;http://msdn.microsoft.com/en-us/library/dd410269.aspx&lt;/a&gt;): 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;table style="border-bottom: #e5e5e5 1px solid; border-left: #e5e5e5 1px solid; margin-top: 5px; width: 97%; border-collapse: collapse; margin-bottom: 5px; margin-left: 0px; border-top: #e5e5e5 1px solid; border-right: #e5e5e5 1px solid"&gt;&lt;tbody&gt;
    &lt;tr style="background-color: #e5e5e5"&gt;
      &lt;th&gt;
        &lt;p&gt;Action Result&lt;/p&gt;
      &lt;/th&gt;

      &lt;th&gt;
        &lt;p&gt;Helper Method&lt;/p&gt;
      &lt;/th&gt;

      &lt;th&gt;
        &lt;p&gt;Description&lt;/p&gt;
      &lt;/th&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.viewresult.aspx"&gt;ViewResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.view.aspx"&gt;View&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Renders a view as a Web page. &lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.partialviewresult.aspx"&gt;PartialViewResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.partialview.aspx"&gt;PartialView&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Renders a partial view, which defines a section of a view that can be rendered inside another view.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.redirectresult.aspx"&gt;RedirectResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirect.aspx"&gt;Redirect&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Redirects to another action method by using its URL.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.redirecttorouteresult.aspx"&gt;RedirectToRouteResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirecttoaction.aspx"&gt;RedirectToAction&lt;/a&gt;&lt;/p&gt;

        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirecttoroute.aspx"&gt;RedirectToRoute&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Redirects to another action method.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.contentresult.aspx"&gt;ContentResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.content.aspx"&gt;Content&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Returns a user-defined content type.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.jsonresult.aspx"&gt;JsonResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.json.aspx"&gt;Json&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Returns a serialized JSON object.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.javascriptresult.aspx"&gt;JavaScriptResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.javascript.aspx"&gt;JavaScript&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Returns a script that can be executed on the client.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.fileresult.aspx"&gt;FileResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.file.aspx"&gt;File&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Returns binary output to write to the response.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td&gt;
        &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.emptyresult.aspx"&gt;EmptyResult&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;(None)&lt;/p&gt;
      &lt;/td&gt;

      &lt;td&gt;
        &lt;p&gt;Represents a return value that is used if the action method must return a null result (void).&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Methods without an ActionResult return type&lt;/strong&gt; 

  &lt;br /&gt;The MVC framework will translate action methods that do not return an ActionResult into one. Consider the HomeController below which has methods that do not return any ActionResult types. The methods defined return an int, object and void respectfully.&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;class&lt;/span&gt; HomeController : Controller&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt; Add(&lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt; x, &lt;span style="color: #006699; font-weight: bold !important"&gt;int&lt;/span&gt; y)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; x + y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; Employee GetEmployee()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; Employee();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;public&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;void&lt;/span&gt; DoNothing()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;When a request comes in, the Controller class hands internally uses a &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controlleractioninvoker.aspx" target="_blank"&gt;ControllerActionInvoker&lt;/a&gt; class which inspects the action parameters and invokes the correct action method. The &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controlleractioninvoker.createactionresult(v=VS.100).aspx" target="_blank"&gt;CreateActionResult&lt;/a&gt; method in the ControllerActionInvoker class is used to return an ActionResult. This method is shown below. If the result of the action method is null, an EmptyResult instance is returned. If the result is not of type ActionResult, the result is converted to a string and returned as a ContentResult.&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: #ffffff; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas,&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: #ffffff; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #006699; font-weight: bold !important"&gt;protected&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;virtual&lt;/span&gt; ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, &lt;span style="color: #006699; font-weight: bold !important"&gt;object&lt;/span&gt; actionReturnValue) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;if&lt;/span&gt; (actionReturnValue == &lt;span style="color: #006699; font-weight: bold !important"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; EmptyResult();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    ActionResult actionResult = (actionReturnValue &lt;span style="color: #006699; font-weight: bold !important"&gt;as&lt;/span&gt; ActionResult) ??&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #006699; font-weight: bold !important"&gt;new&lt;/span&gt; ContentResult { Content = Convert.ToString(actionReturnValue, CultureInfo.InvariantCulture) };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006699; font-weight: bold !important"&gt;return&lt;/span&gt; actionResult;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 9pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;In the HomeController class above, &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the DoNothing method will return an instance of the EmptyResult() 
    &lt;ul&gt;
      &lt;li&gt;Renders an empty webpage &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;the GetEmployee() method will return a ContentResult which contains a string that represents the current object 
    &lt;ul&gt;
      &lt;li&gt;Renders the text “MyNameSpace.Controllers.Employee” without quotes. &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;the Add method for a request of /home/add?x=3&amp;amp;y=5 returns a ContentResult 
    &lt;ul&gt;
      &lt;li&gt;Renders the text “8” without quotes. &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;strong&gt;Unit Testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The nice thing about the ActionResult types is in unit testing the controller. We can, without starting a web server, create an instance of the Controller, call the methods and verify that the type returned is the expected ActionResult type. We can then inspect the returned type properties and confirm that it contains the expected values. 
  &lt;br /&gt;

  &lt;br /&gt;Enjoy! 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sulley: Hey, Mike, this might sound crazy but I don't think that kid's dangerous. 
    &lt;br /&gt;Mike: Really? Well, in that case, let's keep it. I always wanted a pet that could kill me. &lt;/em&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7468223" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rajbk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/rajbk/archive/tags/MVC/default.aspx">MVC</category></item></channel></rss>