<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1088841307441866733</atom:id><lastBuildDate>Fri, 01 Nov 2024 11:01:13 +0000</lastBuildDate><category>NHibernate</category><category>S#arp Architecture</category><category>VirtualAltNet</category><category>Documentation</category><category>Fluent NHibernate</category><category>MVC</category><category>NH Prof</category><category>Nant</category><category>Team City</category><category>ASP.Net</category><category>Active Directory</category><category>Build script</category><category>Certificate Errors</category><category>Continuous Improvement</category><category>Continuous Integration</category><category>Craftsmanship</category><category>DDD</category><category>Fubu Mvc</category><category>Generics</category><category>Horn</category><category>JSON</category><category>JavaScript</category><category>Kerberos</category><category>NUnit</category><category>Open Spaces</category><category>Productivity</category><category>SQL Query cache optimization</category><category>SQL Server 2008</category><category>SQLConnection</category><category>SSAS 2005</category><category>SSL Errors</category><category>Subversion</category><category>TDD</category><category>Visual Studio</category><category>jQuery</category><title>John Leger</title><description>Continuous Improvement In Software Engineering &lt;br&gt;A Passion for Learning</description><link>http://legeronline.blogspot.com/</link><managingEditor>noreply@blogger.com (John Leger)</managingEditor><generator>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-1894794871861794988</guid><pubDate>Fri, 04 Mar 2011 23:32:00 +0000</pubDate><atom:updated>2011-03-11T08:50:59.377-05:00</atom:updated><title>MVP Design Patterns with WinForms</title><description>&lt;p&gt;In this long awaited entry dear reader who is likely only me,&amp;#160; I’ll aim to educate thee with the above noted two design patterns. I’ll highlight Model View Presenter and Model View Controller the latter most typically deployed as web applications and show a few examples of them in action within a windows forms project. &lt;/p&gt;  &lt;p&gt;Our focus will be on separating behavioral and synchronization code away from the view into presentation class objects following the &lt;a href=&quot;http://en.wikipedia.org/wiki/Single_responsibility_principle&quot; target=&quot;_blank&quot;&gt;Single Responsibility Principal&lt;/a&gt; (SRP) coined by &lt;a title=&quot;Uncle Bob&quot; href=&quot;http://www.objectmentor.com/omTeam/martin_r.html&quot; target=&quot;_blank&quot;&gt;Robert C. Martin&lt;/a&gt; closely. &lt;/p&gt;  &lt;p&gt;Applying these principles will result in the ability for us to test the design in smaller granular increments and also test behavior in isolation. I would recommend reading the views of &lt;a title=&quot;GUI Architectures&quot; href=&quot;http://martinfowler.com/eaaDev/uiArchs.html&quot; target=&quot;_blank&quot;&gt;Fowler&lt;/a&gt; on both of these patterns. When all code is self-contained behind the form developers will commonly duplicate common logic throughout the application. This is a definite anti-pattern and a maintenance nightmare. &lt;/p&gt;  &lt;h1&gt;Model View Presenter&lt;/h1&gt;  &lt;p&gt;According to the definition in &lt;a href=&quot;http://en.wikipedia.org/wiki/Model_View_Presenter&quot; target=&quot;_blank&quot;&gt;Wikipedia&lt;/a&gt; the Model View Presenter is a UI design pattern engineered to facilitate automated unit testing and to improve the separation of concerns in the presentation logic. Furthering on from Wikipedia here are the definitions of each term in the pattern.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Model – interface that defines the data that will be displayed and acted upon in the UI &lt;/li&gt;    &lt;li&gt;View – interface that displays the data and routes user commands (events) to the presenter for it to act on &lt;/li&gt;    &lt;li&gt;Presenter – acts upon the model and the view retrieving data from repositories (model), persists it and format it for display in the view. Known as the middle-man assuming the same role as served by the Controller in the MVC pattern &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Pattern Variations&lt;/h2&gt;  &lt;p&gt;There are two main variants to this design pattern namely Passive View and Supervising Controller the latter appearing to be used mostly within web applications.&amp;#160; With the &lt;em&gt;Passive View&lt;/em&gt; interaction with the &lt;em&gt;Model&lt;/em&gt; (data) is handled exclusively by the &lt;em&gt;Presenter&lt;/em&gt;. The &lt;em&gt;View&lt;/em&gt; is updated exclusively by the &lt;em&gt;Presenter&lt;/em&gt;. With &lt;em&gt;Supervising Controller&lt;/em&gt; the &lt;em&gt;View&lt;/em&gt; interacts with the &lt;em&gt;Model&lt;/em&gt; for simple data binding and the &lt;em&gt;View&lt;/em&gt; is updated by the &lt;em&gt;Presenter&lt;/em&gt; via data-binding. &lt;/p&gt;  &lt;h2&gt;Example – Supervising Controller&lt;/h2&gt;  &lt;p&gt;Here is a look at the project within Visual Studio. I have moved assemblies into separate projects. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTlWpER2pfDpjpwIhgGR07Uf3OL6IGC_srhJvqlnmjEzxVTQDw-g_BfdRIaEzaOZZ1GBuWjU-VndpFQy9xlfL-pddqGUR764R19UIS1alToXFHUH4Fkebkzf-l2GAjZvSckjux8LodXMg/s1600-h/BlogMVPVSSetup2.jpg&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;BlogMVPVSSetup&quot; border=&quot;0&quot; alt=&quot;BlogMVPVSSetup&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVZaUfDLCgrMxGY78owxqzLcPpgh1a4lJ4eV7RciY6cqm1cdZsDGptDBn_REUWFXus3DAd0J8QNAsiA0Q2pVigVgjBb0JMvAqHbIhyfEeNENNjQIBn6qvmYSAY5vt3bH3FANDbE4uXvM8/?imgmax=800&quot; width=&quot;171&quot; height=&quot;244&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The separation allows us to let the front-end be completely agnostic. We can easily re-use the assemblies easily within with a web project which is flexible and a good thing! This also allows us to freely test the Presentation layer and domain layer for meeting requirements. This example will focus solely on the Supervising Controller.&amp;#160; &lt;/p&gt;  &lt;p&gt;Here is a screenshot of what we are aiming for. This is not an overly complex UI. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiGr-W6BZJWiUBu0yWB7b0stxnrrTRuyNWYuHOW5fT8MAWo7Y5qFJF1w2bj6ebbs1119Bd1FabXJ1hrpq9DeAvwxPDcH3kEzvyYXs9IkSEjCeM_WeZZtcemj3ZuzYB4rRv-gsn1XUNQDY/s1600-h/BlogMVP12.jpg&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;BlogMVP1&quot; border=&quot;0&quot; alt=&quot;BlogMVP1&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr0dmrnxstKM8JuKhKYcaXlqacWa9Rf5BoTLA1bM7wWTWbMpsJ6x1hYf5-F0lQj5QSD2lf-LCHuD8Hg0rKBuRz1T0jWoFS88YwHanYohBGucIUBkYNacGXUXvhIIjPfLSSQe7lF3sEiYU/?imgmax=800&quot; width=&quot;244&quot; height=&quot;141&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We will send messaging upon the successful completion of a task. When the state is such that success occurs the edit panel will become hidden and the message panel will become visible to the user. This is all handled via a Boolean property contained within the view’s interface. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrXxxwCMXWR9vNvFxbxVi30BkO68nuKII0MvrDRxtVnZJ_iDSTlR81pJMm50QDeh24L2RvxhSu6OJPVDlV2Amotg08ZIGv1LGb0InPKnVu7yTmJlcMJt8KjHi377IgFEeZ5Wvv3HEpWQw/s1600-h/BlogMVPSave2.jpg&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;BlogMVPSave&quot; border=&quot;0&quot; alt=&quot;BlogMVPSave&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCyaCuxsYEtMPNpVqRKViV8UOmIeFbP7EgXF4tWsUG3Dgav1pS33ptqNcQrM2e1CpIBAnhWofKVDpG-E4ybi6dzDrOj3AfY9J3rVm4k4sRoQHMi_xAUdwRgj6hGnSBC6hPgor0D5FqERw/?imgmax=800&quot; width=&quot;244&quot; height=&quot;130&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is a simple class called Task that will become our Model.&lt;/p&gt;  &lt;pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; Task&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; Name { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; Completed { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; DateTime StartDate { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; DateTime CompletionDate { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; Save() {}&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    }&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here is the interface that is passed into the constructor of our Presentation layer.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;interface&lt;/span&gt; ITaskScreen&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; TaskName { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; Completed { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        DateTime StartDate { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        DateTime CompletionDate { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; IsTaskSaved { &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;event&lt;/span&gt; EventHandler&amp;lt;EventArgs&amp;gt; Save;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    }&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Within the constructor we also wire up the data binding for our domain objects values stored in the form. The ViewSave method will set each of the properties in the Model to the values set in the form. After the save finishes we wire up our message and set the visibility of the two panels within the form to their respective required states. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; TaskScreenPresenter&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;readonly&lt;/span&gt; ITaskScreen _view;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; TaskScreenPresenter (ITaskScreen view)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            _view = view;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            Initialize();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; Initialize()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            _view.Save += ViewSave;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; ViewSave(&lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            Task task;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                task = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Task&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                           {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                               Name = _view.TaskName,&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                               StartDate = _view.StartDate,&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                               Completed = _view.Completed,&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                               CompletionDate = _view.CompletionDate&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                           };&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                task.Save();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                _view.IsTaskSaved = &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception ex)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                System.Diagnostics.Debug.WriteLine(ex.Message);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    }&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The code in the view is very compact and easy to get your head around. Lets have a look at that. The view references only the Presentation layer. This provides us with clear separation of responsibility. The view implements the ITaskScreen interface through the Presentation layer. When the view is loaded we call into the constructor of the Presentation layer through a private instance. The IsTaskSaved property sends messaging back to the UI notifying a successful Save action result. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; partial &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; TaskUpdate : Form, ITaskScreen&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; TaskScreenPresenter presenter;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; OnLoad(EventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;base&lt;/span&gt;.OnLoad(e);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            presenter = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; TaskScreenPresenter(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; TaskUpdate()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            InitializeComponent();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; btnSaved_Click(&lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (Save != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                Save(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;, EventArgs.Empty);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; TaskName&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; txtTaskName.Text; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; Completed&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; chkComplete.Checked; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; DateTime StartDate&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; Convert.ToDateTime(txtStartDate.Text); }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; DateTime CompletionDate&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; Convert.ToDateTime(txtCompleteDate.Text); }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; IsTaskSaved&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                pnlEdit.Visible = &lt;span style=&quot;color: #0000ff&quot;&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;                pnlMessage.Visible = &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;            }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;event&lt;/span&gt; EventHandler&amp;lt;EventArgs&amp;gt; Save;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&quot;&gt;    }&lt;/pre&gt;&lt;/pre&gt;  </description><link>http://legeronline.blogspot.com/2011/03/mvp-design-patterns-with-winforms.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVZaUfDLCgrMxGY78owxqzLcPpgh1a4lJ4eV7RciY6cqm1cdZsDGptDBn_REUWFXus3DAd0J8QNAsiA0Q2pVigVgjBb0JMvAqHbIhyfEeNENNjQIBn6qvmYSAY5vt3bH3FANDbE4uXvM8/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-6042601260647880313</guid><pubDate>Fri, 12 Nov 2010 15:07:00 +0000</pubDate><atom:updated>2010-11-12T13:52:47.870-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Craftsmanship</category><category domain="http://www.blogger.com/atom/ns#">TDD</category><title>Craftsmanship</title><description>I am starting to re-flex the writing muscle. It&#39;s been a while. I listened to a great discussion on TDD this morning via &lt;a href=&quot;http://www.se-radio.net/2010/09/episode-167-the-history-of-junit-and-the-future-of-testing-with-kent-beck/&quot;&gt;Software Engineering Radio&lt;/a&gt;. Kent Beck delivers a very interesting view on the subject. I think this is required listening by all participants who value their contributions to the craft of software development. It&#39;s time to shed any prior &lt;a href=&quot;http://www.urbandictionary.com/define.php?term=Dumbpiphany&quot;&gt;dumbpiphany&lt;/a&gt; conversations regarding the evolution of a software development project. Enjoy your brew!</description><link>http://legeronline.blogspot.com/2010/11/craftsmanship.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-988557513103389886</guid><pubDate>Tue, 15 Dec 2009 14:33:00 +0000</pubDate><atom:updated>2010-01-06T13:26:54.735-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Fubu Mvc</category><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><category domain="http://www.blogger.com/atom/ns#">JSON</category><category domain="http://www.blogger.com/atom/ns#">MVC</category><title>Using jQuery on the client with JSON data for smart client-side data filtering</title><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;Background&lt;/h3&gt; &lt;p&gt;Recently I started using some of the more advanced features of &lt;a href=&quot;http://jquery.com/&quot; target=&quot;_blank&quot;&gt;jQuery&lt;/a&gt; via a &lt;a href=&quot;http://code.google.com/p/fubumvc/&quot; target=&quot;_blank&quot;&gt;FUBU MVC&lt;/a&gt; project and from this experience I have grown a deep love and appreciation for the power it brings to the web developers set of tools. jQuery is a full-featured library add-in to JavaScript that enables &lt;a href=&quot;http://en.wikipedia.org/wiki/Document_Object_Model&quot; target=&quot;_blank&quot;&gt;DOM&lt;/a&gt; traversal. To more easily grok what jQuery sets out to accomplish, think of traversing the browser DOM in a SQL query like manner. With jQuery I will demonstrate that you can easily parse through a &lt;a href=&quot;http://json.org/&quot; target=&quot;_blank&quot;&gt;JSON&lt;/a&gt; data set stored in the DOM. The solution requires client side filtering for three selectors that reside on a page that displays a grid of data. The users desire an AJAX like selection process. We will store the JSON data in a hidden field mimicking the initial data set. This hidden field will additionally contain fields for the client-side filtering that are not part of the grids initial display. &lt;/p&gt; &lt;h3&gt;View Models&lt;/h3&gt; &lt;p&gt;FUBU MVC is an opinionated approach to web development. One of the underlying concepts of the FUBU MVC architecture that I think is fundamentally strong is what the authors refer to as the “Thunderdome Principal”. One model in and one model out. As I mentioned at the outset above, our out model defined for the view will need a property containing the entire record set that’s initially sent to the view together with additional filter selectors. To aid in the transformation to and from jQuery to JSON we will utilize an additional jQuery plug-in called &lt;a href=&quot;http://code.google.com/p/jquery-json/&quot; target=&quot;_blank&quot;&gt;jQuery-JSON&lt;/a&gt;. &lt;a href=&quot;http://elegantcode.com/2009/11/06/using-serialized-json-to-move-complex-data-to-and-from-the-browser/&quot; target=&quot;_blank&quot;&gt;Jason Grundy&lt;/a&gt;, one of the Elegant Coders provides an insightful discussion on this plug-in and complements the ideas I will discuss here together with applicable code for wiring up the solution. The idea is not that difficult. A word of caution, when your data set is in the thousands of rows this approach may not be the most sensible choice due to the amount of data passing over the wire. The first step is to utilize the JavaScriptSerializer class that is contained within the &lt;em&gt;System.Web.Script.Serialization&lt;/em&gt; namespace. To serialize data to the client, simply call the Serialize method and conversely to fill a property with JSON data coming back from the client call the Deserialize method. The MapLocations property below is of type IEnumerable&amp;lt;T&amp;gt; and is initially mapped to a user control contained within our view that will render a list of mapping locations. We will include three drop-down selectors directly above the grid of map locations for implementing the client side filtering requirement. The property TargetMapLocationsListJson which is of type string, will contain the data in JSON format for the grid and also the fields required for filtering.&lt;/p&gt; &lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt; outModel.MapLocations = locationList;&lt;/pre&gt;&lt;pre&gt; outModel.TargetMapLocationsListJson = _javaScriptSerializer.Serialize( outModel.MapLocations);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;h3&gt;View&lt;/h3&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;selectedMapLocations&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;data-grid&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;thead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                                Store Name&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                                Sales&lt;/pre&gt;&lt;pre&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                                Number of Employees&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                                Action&lt;/pre&gt;&lt;pre&gt;                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;thead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tbody&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class=&quot;asp&quot;&gt;&amp;lt;%&lt;/span&gt;=&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.RenderPartial().Using&amp;lt;ListMapLocationsView&amp;gt;().WithDefault&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                            (&lt;span class=&quot;str&quot;&gt;&quot;No locations exist for these choices&quot;&lt;/span&gt;).WithoutItemWrapper().WithoutListWrapper()&lt;/pre&gt;&lt;pre&gt;                                                    .ForEachOf(Model.MapLocations)&lt;span class=&quot;asp&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tbody&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Our view model that displays the grid of map locations passes into the filtered list view a strongly typed list of store locations that are rendered by a ForEachOf HTML helper extension included within the FUBU MVC’s core framework. &lt;a href=&quot;http://elegantcode.com/2009/03/08/fubumvc-from-scratch-part-3-adding-view-to-project/&quot; target=&quot;_blank&quot;&gt;Ryan Kelley&lt;/a&gt; of Elegant Code wrote a great series on FUBU MVC and he covers wiring up the view model with the view in greater detail than I will here. If you are committed to using the FUBU MVC architecture I highly recommend that you check out his 4 part series.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;We set up a hidden control on the page to hold the serialized JSON data that will mimic what is displayed within the selectedMapLocations div that is populated with another FUBU MVC helper extension called the HiddenFor control.&lt;/p&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;mapLocationsList&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre&gt;                &lt;span class=&quot;asp&quot;&gt;&amp;lt;%&lt;/span&gt;= &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.HiddenFor(x =&amp;gt; x.TargetMapLocationsListJson).ElementId(&lt;span class=&quot;str&quot;&gt;&quot;targetMapLocationsListJSON&quot;&lt;/span&gt;)&lt;span class=&quot;asp&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;p align=&quot;left&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&amp;nbsp;&lt;/h3&gt;&lt;br /&gt;&lt;h3&gt;JavaScript&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;And now we can move on to the JavaScript. There will not be any server involvement until the user clicks the submit button. You will note above in the HTML for the data-grid that we have included a column named Action. This column will contain a button click event allowing the user to add the various map locations to their profile. This will add the location selection to a hidden field that is converted to JSON so that we can Deserialize the selections on the server. We will then add each of the selections to IEnumerable&amp;lt;T&amp;gt; property that is contained within the Domain object. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;On document ready we created a function that contains initialization methods, event handling routines and associated helper routines. We set three global Boolean properties to false. As previously noted we use three filters that are invoked by dropdown controls. On initialization each of these dropdown controls are set to null. Then each of the dropdown event handlers are instantiated. When a user changes a selection the event handler associated to the dropdown control fires as noted below for State. &lt;/p&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;            &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; initSelectedStateChangeEventHandling() {&lt;/pre&gt;&lt;pre&gt;                $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-state&quot;&lt;/span&gt;).change(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (stateChanged == &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt; &amp;amp;&amp;amp; $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).val() == &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                    $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-state option:selected&quot;&lt;/span&gt;).each(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        stateChanged = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                        findMapLocationsByFilter($(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).val(), &lt;span class=&quot;str&quot;&gt;&#39;state&#39;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    })&lt;/pre&gt;&lt;pre&gt;                });&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;            }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;What should be evident from the above JavaScript snippet is that when the Boolean property is no longer false and the selection value is not null then we for each through the users selection choices and call into a function that performs the client-side filtering. Lets have a look at the findMapLocationsByFilter function.&lt;/p&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;            &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; findMapLocationsByFilter(criteria, filterType) {&lt;/pre&gt;&lt;pre&gt;                &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; originalList = $(&lt;span class=&quot;str&quot;&gt;&#39;tbody&#39;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                originalList.find(&lt;span class=&quot;str&quot;&gt;&#39;tr,td&#39;&lt;/span&gt;).remove();&lt;/pre&gt;&lt;pre&gt;                &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; data = $(&lt;span class=&quot;str&quot;&gt;&quot;#targetMapLocationListJSON&quot;&lt;/span&gt;).val();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (data == &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                $.each($.evalJSON(data), &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    originalList.append(getSelectedFilteredMapsHtml(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;, criteria, filterType));&lt;/pre&gt;&lt;pre&gt;                });&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;            }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This is a generic function that is used by all dropdown selectors. In this function we utilize jQuery selectors for the existing content within the &lt;em&gt;&lt;strong&gt;tbody&lt;/strong&gt;&lt;/em&gt; element. We then modify the selector to contain only the elements within the tr and td tags. We then call the remove method on the content contained within the elements. A new selector is instantiated with the content contained in the hidden field that is structured as JSON data. We utilize the jQuery for each method together with the jQuery-JSON plugin’s evalJSON method. Each data element in the hidden field is passed into another function that will append the filtered content back into the selector that we previously cleared. Lets now have a look and the getSelectedFilteredMapsHtml function.&lt;/p&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; getSelectedFilteredmapsHtml(mapData, criteria, filterType) {   &lt;/pre&gt;&lt;pre&gt;        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (filterHasData(mapData, criteria, filterType)) {   &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;blockquote style=&quot;margin-right: 0px&quot; dir=&quot;ltr&quot;&gt;&lt;p&gt;        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;tr id=&quot;&lt;/span&gt; + &lt;span class=&quot;str&quot;&gt;&quot;maplocations-maplist-row-&quot;&lt;/span&gt; + mapData.mapId + &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt; + &lt;span class=&quot;str&quot;&gt;&quot; stateId=&quot;&lt;/span&gt; + mapData.StateId    &lt;/p&gt;&lt;/blockquote&gt;&lt;/pre&gt;&lt;pre&gt;                + &lt;span class=&quot;str&quot;&gt;&quot; countyId=&quot;&lt;/span&gt; + mapData.CountyId + &lt;span class=&quot;str&quot;&gt;&quot; zipId=&quot;&lt;/span&gt; + mapData.ZipCodeId + &lt;span class=&quot;str&quot;&gt;&quot;&amp;gt;&quot;&lt;/span&gt;   &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;td id=&#39;storeName&#39;&amp;gt;&quot;&lt;/span&gt; + mapData.StoreName + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/td&amp;gt;&quot;&lt;/span&gt;   &lt;/pre&gt;&lt;pre&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;td id=&#39;sales&#39;&amp;gt;&quot;&lt;/span&gt; + mapData.Sales + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/td&amp;gt;&quot;&lt;/span&gt;   &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;td id=&#39;numEmployees&#39;&amp;gt;&quot;&lt;/span&gt; + mapData.NumberOfEmployees + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/td&amp;gt;&quot;&lt;/span&gt;   &lt;/pre&gt;&lt;pre&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;td id=&#39;includemaps&#39;&amp;gt;&quot;&lt;/span&gt;  &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;span class=&#39;form-item&#39;&quot;&lt;/span&gt; + &lt;span class=&quot;str&quot;&gt;&quot;&amp;gt;&quot;&lt;/span&gt;  &lt;/pre&gt;&lt;pre&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;input id=&quot;&lt;/span&gt; + &lt;span class=&quot;str&quot;&gt;&quot;save-maplocations-&quot;&lt;/span&gt; + mapData.mapId + &lt;span class=&quot;str&quot;&gt;&quot; type=button&quot;&lt;/span&gt; +  &lt;span class=&quot;str&quot;&gt;&quot; value=&#39;Include Location&#39;&quot;&lt;/span&gt; + &lt;span class=&quot;str&quot;&gt;&quot;&amp;gt;&amp;lt;/input&amp;gt;&quot;&lt;/span&gt;  &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/span&amp;gt;&quot;&lt;/span&gt;  &lt;/pre&gt;&lt;pre&gt;                + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&quot;&lt;/span&gt;; &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;blockquote&gt;&lt;p&gt;       }  &lt;/p&gt;&lt;/blockquote&gt;&lt;/pre&gt;&lt;pre&gt;              }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Clearly there will not be any row returned if the filter contains no data. The filterHasData function compares the stateId within the JSON data to the value of the selectors changed stateId. If they are equal then we return and append content back to the div we cleared earlier. The filterHasData function is quite simple and shown below.&lt;/p&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;            function filterHasData(mapData, criteria, filterType) {&lt;/pre&gt;&lt;pre&gt;                &lt;span class=&quot;kwrd&quot;&gt;switch&lt;/span&gt; (filterType) {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;state&quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre&gt;                        $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-county&quot;&lt;/span&gt;).val(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-zip&quot;&lt;/span&gt;).val(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;); &lt;/pre&gt;&lt;pre&gt;                        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (mapData.StateId == criteria);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;county&quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-state&quot;&lt;/span&gt;).val(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;                        $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-zip&quot;&lt;/span&gt;).val(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);                        &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (mapData.CountyId == criteria);&lt;/pre&gt;&lt;pre&gt;                        &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                    &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;zip&quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre&gt;                        $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-state&quot;&lt;/span&gt;).val(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        $(&lt;span class=&quot;str&quot;&gt;&quot;#list-maplocations-county&quot;&lt;/span&gt;).val(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;                        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (mapData.ZipCodeId == criteria);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class=&quot;kwrd&quot;&gt;default&lt;/span&gt;:&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;                        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;            }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;What has become quite evident to me from having dabbled in a couple of MVC frameworks is the importance of knowing how to use JavaScript correctly. Adding a few extensions to it really assists you in developing smarter and more powerful UI experiences. For added assistance I would recommend the following books: &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Manning – &lt;a href=&quot;http://www.manning.com/bibeault/&quot; target=&quot;_blank&quot;&gt;jQuery in Action, Bear Bibeault &amp;amp; Yehuda Katz&lt;/a&gt; &lt;br /&gt;&lt;li&gt;O’Reilly – &lt;a href=&quot;http://oreilly.com/catalog/9780596517748&quot; target=&quot;_blank&quot;&gt;JavaScript: The Good Parts, Douglas Crockford&lt;/a&gt; &lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;I hope to post a detailed solution with all code in the near future. I appreciate any comments or alternatives the approach I have taken.&lt;/p&gt;  </description><link>http://legeronline.blogspot.com/2009/12/using-jquery-on-client-with-json-data.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-4894617712457412947</guid><pubDate>Sun, 04 Oct 2009 05:53:00 +0000</pubDate><atom:updated>2009-10-04T02:22:29.295-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">NH Prof</category><category domain="http://www.blogger.com/atom/ns#">NHibernate</category><title>NH Profiler – Using Filters to find the needle in the haystack</title><description>&lt;p&gt;The &lt;a title=&quot;NHProf.com&quot; href=&quot;http://nhprof.com&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;NHibernate Profiler&lt;/a&gt; allows a developer to analyze the behaviors between the domain and data layer more effectively. If you are using NHibernate I think this piece of software should be in your arsenal of tools. Oh, and for you Java folks it works against Hibernate. &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7Z0KJOpFcrz-cHxenRI2HOBn2wOXe-vHuj4YvhG7RZC_XZ3Ttmdix_CNWFNklI8jdxHWnB22wCw2k43qs0TsmBb9kps5EOaZwV7sM1njFrZMU_0Gav9KrgdlwnEfewm44Mps5bsxhDWI/s1600-h/image3.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;left&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEKkbcgBtakGuIflZxILdB715BNly7lkgl5Oaa0eIs09TqhDg1p3oCUq8dI58o72KheK-ZZBmLHcH6RMERs0LLAXtYj3BNNlfhUBb0ts8JL3cni1rCMXvh4OUXexQLi5G8GijeKUNW7OU/?imgmax=800&quot; width=&quot;192&quot; height=&quot;244&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Session Filtering&lt;/h3&gt;  &lt;p&gt;Before I start the analysis notice to the left we have an unfiltered view of our current sessions. If you look a bit closer, you’ll notice that the recent statements list contains some added &lt;em&gt;noise.&lt;/em&gt; To remedy this we will apply a filter to all session statements containing a url path for image,css and JavaScript files.&lt;/p&gt;  &lt;p&gt;Locate the Filter component, in the upper right window of NH Profiler. &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd1BUdfiVM2GTww_u12wvyz53ztfMMbMqOues4lDl6Lg_VrDzybB4u75vljOWk2ln2HKqMB4dno4YwhG2iHKLUru2DIupf7-4SeIrUtQ3oblxT5_FpctJpP5E34SmrJHt8ouq9HqbGoHE/s1600-h/image11%5B1%5D.png&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-JBeMMdZFcoqs6LAjwOXJtxZ4gfN9JXtyN-2piv2rZX75J9H_GyAKkvGJ7m9hZixbeNKck2I_5N2EMRTVHT67dDqGV8KcMs0aC_UTJx_p1HaPg3G4OGgUKrt8Y_DE4opzH4VIzh3RE1o/?imgmax=800&quot; width=&quot;244&quot; height=&quot;57&quot; /&gt;&lt;/a&gt;By default filtering is &lt;em&gt;Inactive.&lt;/em&gt; So lets define one custom to our session!&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Click on the filter icon and in the dropdown list of the Edit Filter window choose filtering for&amp;#160; “Sessions by URL. &lt;/li&gt;    &lt;li&gt;Click the Add button. &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSXILaHpZ6udrzTG8fPVer6qVJVb3JDxNB-tpiH0stoe9eaMEEHdjVWRx2MTVCNDTZq1ZKmoiFt8P-skrW5REbtXMu7UwdK5Ock1z88S0FA__7IFedQQZY_RPxuVUwCP7v_iqlIRrk35E/s1600-h/image15%5B1%5D.png&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEyoZMw7VyLpPgpnldq2857vA7BpUB4l-RJOBrwrqaX5HIqGRgfyySWdawXWYAJYEkyhR01asXemiFzemqwjFmMUgcqdA8vkcPcWNTlbhX6iEQskZLC0ATVJxztKHCaSp4K-kzJsoJQbE/?imgmax=800&quot; width=&quot;244&quot; height=&quot;179&quot; /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Choose the not containing operator. &lt;/li&gt;    &lt;li&gt;Enter the text for filtering. In my example I want to filter URL’s being sourced with the text &#39;/Assets/’.&amp;#160; &lt;/li&gt;    &lt;li&gt;Click apply. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;And voila! we now have a more concise session list.&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsyag1QziawvoNMmrw46ort5tI_lg70lqLmvnc09QUC3jb8PAuO3A6Y-z6tOME1KLATk3kdHpvZC3poLt5Zmm6nqM_fFXMn3seGLvMiC967h2HaVcRhAW8_r3nIqzmIvYnqzMZWe4c1qs/s1600-h/image21.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8io_r0NKP4HPs316Eqjaumub40D0i-5eQTbfKc_35kRIbQvWR7gT_yiXhXogrmEo3o4GkccHmPchC74vZyWemXil1NWQHJoOlqPsmI1pIj98hVYnjbUNZXL9i9R-ZLSauDLXKmGUBRIw/?imgmax=800&quot; width=&quot;244&quot; height=&quot;153&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt; When the analysis is complex try to make it simpler with &lt;strong&gt;filters! &lt;/strong&gt;In a future discussion we will look into how NH Prof can diff sessions and what insight we can gain from doing this. &lt;/p&gt;  </description><link>http://legeronline.blogspot.com/2009/10/nh-profiler-performance-testing-tricks.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEKkbcgBtakGuIflZxILdB715BNly7lkgl5Oaa0eIs09TqhDg1p3oCUq8dI58o72KheK-ZZBmLHcH6RMERs0LLAXtYj3BNNlfhUBb0ts8JL3cni1rCMXvh4OUXexQLi5G8GijeKUNW7OU/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-1038892089347189357</guid><pubDate>Thu, 10 Sep 2009 14:50:00 +0000</pubDate><atom:updated>2009-09-15T17:40:55.705-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Fluent NHibernate</category><category domain="http://www.blogger.com/atom/ns#">Horn</category><category domain="http://www.blogger.com/atom/ns#">S#arp Architecture</category><title>Part 2 - Extending Sharp Architecture with the version 1.0 of Fluent NHibernate’s ManyToManyTableConvention</title><description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In my last &lt;a href=&quot;http://legeronline.blogspot.com/2009/08/sarp-architecture-part-1-implementing.html&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt; I showed how to override S#arp Architecture’s implementation of Fluent NHibernate’s auto-mapping conventions. In the text that follows we will show how you can easily continue following the &lt;em&gt;default&lt;/em&gt; behavior of S#arp Architecture and use convention over configuration. We will add a convention mapping strategy to automatically handle &lt;em&gt;ManyToMany&lt;/em&gt; relationships. In doing so S#arp Architecture will be enabled to work with M:M entity relationships by default out of the box. &lt;/p&gt;  &lt;p&gt;Before we dive into the implementation of code changes to facilitate this functionality, we will review the steps that will be required to implement some of the new &lt;a title=&quot;FluentNHibernate&quot; href=&quot;http://fluentnhibernate.org&quot; target=&quot;_blank&quot;&gt;FNH&lt;/a&gt; Interface improvements and changes introduced with the version 1.0 release. Our current project is based off of S#arp Architecture 1.0 which uses the version preceding Fluent NHibernate 1.0. Our project was previously using NHibernate 2.1.0.3001 and the new version of Fluent NHibernate compiles to NHibernate 2.1.0.4000. There has been mention by others that the Castle stack being used in S#arp Architecture requires an update also. In my situation the only Castle component requiring updating was to down-grade the Castle byte code provider from version 2.1.0.5642 to 2.1.0.0. &lt;/p&gt;  &lt;h3&gt;The Detour – Housekeeping tasks&lt;/h3&gt;  &lt;p&gt;I used a great new tool named &lt;a title=&quot;Horn Get (Google CodeLand)&quot; href=&quot;http://code.google.com/p/hornget/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Horn&lt;/a&gt; to ease the pain of upgrading versions of Fluent NHibernate and its interdependent parts. I have heard about Horn for a while but had not spent any cycles on it till now. There is a great thread on the S#arp Architecture Google group discussion &lt;a title=&quot;HowTo: Update your solution to NHibernate 2.1 and Castle 2.0&quot; href=&quot;http://groups.google.com/group/sharp-architecture/browse_thread/thread/f37a99ecfa681770?hl=en&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;forum&lt;/a&gt; where a frustrated individual lamented the pain of upgrading Open Source Software. Horn also contains a &lt;a title=&quot;Development group discussion&quot; href=&quot;http://groups.google.co.uk/group/horn-development&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt; discussion group and has a &lt;a href=&quot;http://code.google.com/p/horn-contrib/&quot; target=&quot;_blank&quot;&gt;contrib&lt;/a&gt; group. It’s still in the infancy stages but is definitely worth a look. After downloading the binary of Horn, build it and then issue the following command line statements:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Horn –install:fluentnhibernate&lt;/p&gt;    &lt;p&gt;Horn –install:nhibernate.validator&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Through trial and error when building S#arp Architecture with the new version of NHibernate the existing NHibernate Validator assembly did not work properly with version 2.1.0.4 of NHibernate. Horn will look-up FNH’s hard dependencies, retrieve the projects and build them within your local Horn &lt;em&gt;Package Tree&lt;/em&gt;. As an example I recently installed the &lt;a title=&quot;A convention-based object-object mapper&quot; href=&quot;http://www.codeplex.com/AutoMapper&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;AutoMapper&lt;/a&gt; project by Jimmy Bogard. I issed the following command line arguments against Horn.exe:&lt;/p&gt;  &lt;p&gt;Horn –install:automapper&lt;/p&gt;  &lt;p&gt;and a&amp;#160; little over a minute the &lt;strong&gt;result&lt;/strong&gt; folder is populated as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9TENSBaAzFxWhKV0R4_6vluSJ3QQNuhsiNyWFwVZhpqC4kbC424Rd46IPbcAvEyjViSd5trUDZXuNqtoZMWf8mkJ9UCREGWveOW7eIUmmBAWeP-feoQIB6m8KjL1hxJzPfaCqdJUFbJk/s1600-h/Horn1%5B3%5D.gif&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;Horn1&quot; border=&quot;0&quot; alt=&quot;Horn1&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHK82OWEK0UlR4kEZ_B9cxuDt9CfA1KeaKNP8QAV1VTFltF9mGEi956SMzK72tAxQxF4fKV-uNkTeRZXv_xdjqrziM7qJaDvA-F7fQd-_eZhXTvhnqD1Dz_Ui9XP0WRuzUKCorJJ8DZpk/?imgmax=800&quot; width=&quot;640&quot; height=&quot;262&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;All updated assemblies and any required dependent assemblies are placed into this location. Take the rebuilt assemblies from this folder and add them to your S#arp Architecture’s lib folder location. Rebuild the binaries for S#arp Architecture and then copy these binaries together with the updated binaries for Fluent NHibernate, NHibernate, NHibernate Validator to your project’s lib folder. Rebuild your project solution and it will likely fail with the following error:&lt;/p&gt;  &lt;h3&gt;Server Error in &#39;/&#39; Application.    &lt;hr size=&quot;1&quot; width=&quot;100%&quot; /&gt;&lt;/h3&gt;  &lt;h4&gt;&lt;i&gt;Could not load file or assembly &#39;NHibernate, Version=2.1.0.3001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4&#39; or one of its dependencies. The located assembly&#39;s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)&lt;/i&gt;&lt;/h4&gt;  &lt;p&gt;The fix for this is to add a dependent assembly binding entry for the NHibernate 2.1.0.4000 binary in your web.config file. This was likely required to get the S#arp Architecture binaries to fully compile with an app.config entry and is sometimes forgotten in the projects that use the core framework libraries. Place the following configuration settings in your web config file’s &amp;lt;runtime&amp;gt; tag:&lt;/p&gt;  &lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;dependentAssembly&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;assemblyIdentity &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;NHibernate&lt;/span&gt;&amp;quot;  &lt;span style=&quot;color: red&quot;&gt;publicKeyToken&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;AA95F207798DFDB4&lt;/span&gt;&amp;quot; &lt;span style=&quot;color: red&quot;&gt;culture&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;neutral&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;/&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;bindingRedirect &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;oldVersion&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;0.0.0.0-65535.65535.65535.65535&lt;/span&gt;&amp;quot; &lt;span style=&quot;color: red&quot;&gt;newVersion&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;2.1.0.4000&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;/&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;dependentAssembly&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a title=&quot;Upgrade S#arp Architecute to FNH 1.0&quot; href=&quot;http://tomcabanski.spaces.live.com/blog/cns!E0D3617496209F45!124.entry&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Tom Cabanski&lt;/a&gt; wrote a detailed 3 part series on individual changes required to get the conventions to compile with FNH 1.0. I recommend you review and make the changes that make sense for your projects use of the FNH conventions.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font color=&quot;#cc6600&quot;&gt;Addition of new convention classes&lt;/font&gt;&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The Fluent NHibernate convention classes are located within your data assembly and are organized within a folder named NHibernateMaps as follows:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibKMAEzDjXYMJv0UCrmdSaMYXN5FtuCqLk3-O_QSvFK8OdGdtUb9QEFND9Eq1uODFFVr5mHs2PliMeuTmFG7jRwV-1kEDxCwzY_Ru9iLQBpsEhSUGv-S-At2zgzs7BBXxgYjl7WrF2Rfw/s1600-h/FNHChanges%5B4%5D.gif&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;FNHChanges&quot; border=&quot;0&quot; alt=&quot;FNHChanges&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhRePfv8tHVvEq7DYilNszxhFKADDiPPPFz5FHO64Y1FitZguS1il36Gs2Mja7FvNcf_qXHM2Oq9RJO2dW1bdqp7TRoTYYmzqnWg-a9Fki-iLurFCahRPzxW0EG60AhCXGlblbfPOcNC0/?imgmax=800&quot; width=&quot;330&quot; height=&quot;302&quot; /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I have added CustomManyToManyTableNameConvention and HasManyToManyConvention classes to the Conventions folder. Also notice the exclusion of the mapping classes. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Implement a class to derive from the ManyToManyTableNameConvention base class&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;public class &lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;CustomManyToManyTableNameConvention &lt;/span&gt;: &lt;span style=&quot;color: #2b91af&quot;&gt;ManyToManyTableNameConvention&lt;br /&gt;    &lt;/span&gt;{&lt;br /&gt;        &lt;span style=&quot;color: blue&quot;&gt;protected override string &lt;/span&gt;GetBiDirectionalTableName(&lt;span style=&quot;color: #2b91af&quot;&gt;IManyToManyCollectionInspector &lt;/span&gt;collection, &lt;br /&gt;            &lt;span style=&quot;color: #2b91af&quot;&gt;IManyToManyCollectionInspector &lt;/span&gt;otherSide)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style=&quot;color: blue&quot;&gt;return &lt;/span&gt;Inflector.Net.&lt;span style=&quot;color: #2b91af&quot;&gt;Inflector&lt;/span&gt;.Pluralize(collection.EntityType.Name) +&lt;br /&gt;                Inflector.Net.&lt;span style=&quot;color: #2b91af&quot;&gt;Inflector&lt;/span&gt;.Pluralize(otherSide.EntityType.Name);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style=&quot;color: blue&quot;&gt;protected override string &lt;/span&gt;GetUniDirectionalTableName(&lt;span style=&quot;color: #2b91af&quot;&gt;IManyToManyCollectionInspector &lt;/span&gt;collection)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style=&quot;color: blue&quot;&gt;return &lt;/span&gt;Inflector.Net.&lt;span style=&quot;color: #2b91af&quot;&gt;Inflector&lt;/span&gt;.Pluralize(collection.EntityType.Name) + &lt;br /&gt;                Inflector.Net.&lt;span style=&quot;color: #2b91af&quot;&gt;Inflector&lt;/span&gt;.Pluralize(collection.ChildType.Name);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Our custom implementation of the ManyToManyTableNameConvention base class includes overrides for the table names for either Bidirectional or Unidirectional associations. This is a recommended approach from James Gregory to avoid tables being created for either side of the respective associations.&amp;#160; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Implement a class deriving from the IHasManyToManyConvention&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;    &lt;span style=&quot;color: blue&quot;&gt;public class &lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;HasManyToManyConvention &lt;/span&gt;: &lt;span style=&quot;color: #2b91af&quot;&gt;IHasManyToManyConvention&lt;br /&gt;    &lt;/span&gt;{&lt;br /&gt;        &lt;span style=&quot;color: blue&quot;&gt;public void &lt;/span&gt;Apply(&lt;span style=&quot;color: #2b91af&quot;&gt;IManyToManyCollectionInstance &lt;/span&gt;instance)&lt;br /&gt;        {   &lt;br /&gt;            instance.Cascade.SaveUpdate();&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Implement A Class to Override Foreign Key Naming For M:M and M:O Associations&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;public class &lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;CustomForeignKeyConvention &lt;/span&gt;: &lt;span style=&quot;color: #2b91af&quot;&gt;ForeignKeyConvention&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style=&quot;color: blue&quot;&gt;protected override string &lt;/span&gt;GetKeyName(&lt;span style=&quot;color: #2b91af&quot;&gt;PropertyInfo &lt;/span&gt;property, &lt;span style=&quot;color: #2b91af&quot;&gt;Type &lt;/span&gt;type)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style=&quot;color: blue&quot;&gt;if &lt;/span&gt;(property == &lt;span style=&quot;color: blue&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;            &lt;span style=&quot;color: blue&quot;&gt;return &lt;/span&gt;type.Name + &lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;ID&amp;quot;&lt;/span&gt;;&lt;br /&gt;        &lt;span style=&quot;color: blue&quot;&gt;return &lt;/span&gt;property.Name + &lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;ID&amp;quot;&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In all there is very little code to implement this new convention. The convention is bootstrapped as follows in the AutoPersistenceModelGenerator class. Focus your attention to the GetConventions method.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  &lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;public &lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;AutoPersistenceModel &lt;/span&gt;Generate()&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: blue&quot;&gt;var &lt;/span&gt;mappings = &lt;span style=&quot;color: blue&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;AutoPersistenceModel&lt;/span&gt;();&lt;br /&gt;        mappings.AddEntityAssembly(&lt;span style=&quot;color: blue&quot;&gt;typeof&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;AppUser&lt;/span&gt;).Assembly).Where(GetAutoMappingFilter);&lt;br /&gt;        mappings.Conventions.Setup(GetConventions());&lt;br /&gt;        mappings.IgnoreBase&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;Entity&lt;/span&gt;&amp;gt;();&lt;br /&gt;        mappings.IgnoreBase(&lt;span style=&quot;color: blue&quot;&gt;typeof&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;EntityWithTypedId&lt;/span&gt;&amp;lt;&amp;gt;));&lt;br /&gt;        mappings.UseOverridesFromAssemblyOf&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AutoPersistenceModelGenerator&lt;/span&gt;&amp;gt;();&lt;br /&gt;    &lt;span style=&quot;color: blue&quot;&gt;return &lt;/span&gt;mappings;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;private static &lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;Action&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;IConventionFinder&lt;/span&gt;&amp;gt; GetConventions()&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: blue&quot;&gt;return &lt;/span&gt;c =&amp;gt; {&lt;br /&gt;        c.Add&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;PrimaryKeyConvention&lt;/span&gt;&amp;gt;();&lt;br /&gt;        c.Add&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;ReferenceConvention&lt;/span&gt;&amp;gt;();&lt;br /&gt;        c.Add&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;HasManyConvention&lt;/span&gt;&amp;gt;();&lt;br /&gt;        c.Add&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;HasManyToManyConvention&lt;/span&gt;&amp;gt;();&lt;br /&gt;        c.Add&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;TableNameConvention&lt;/span&gt;&amp;gt;();&lt;br /&gt;        c.Add&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;CustomManyToManyTableNameConvention&lt;/span&gt;&amp;gt;();&lt;br /&gt;        c.Add&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;CustomForeignKeyConvention&lt;/span&gt;&amp;gt;();&lt;/pre&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;    };&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Within my test runs I perform sanity checks on my NHibernate maps and save schema and HBM file changes. Here is an excerpt from the test run showing just the areas of interest from introducing the new convention classes. What becomes apparent and is real cool is that the default for collection associations is a bag. I presume this is so since I am using an IList to manage this collection in either side of the association and FNH uses reflection to auto set the relationship to the .Net equivalent of the bag which is an IList. By default the inverse of the relationship is added without any explicit code and to the correct side of the relationship! This is pretty freaking cool if you ask me.&amp;#160; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h5&gt;Role.hbm.xml&lt;/h5&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;hibernate-mapping &lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;xmlns&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;urn:nhibernate-mapping-2.2&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;default-access&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;property&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;auto-import&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;true&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;default-cascade&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;none&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;default-lazy&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;true&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt; …&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;bag &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;cascade&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;save-update&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style=&quot;color: red&quot;&gt;inverse&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;true&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style=&quot;color: red&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;AppUsers&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style=&quot;color: red&quot;&gt;table&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;AppUsersRoles&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;key&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;column &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;RoleID&lt;/span&gt;&amp;quot; &lt;span style=&quot;color: blue&quot;&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;key&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;many-to-many &lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;VirtualAltNetRTM.Core.AppUser, &lt;br /&gt;                    VirtualAltNetRTM.Core, &lt;br /&gt;                    Version=1.0.0.0, &lt;br /&gt;                    Culture=neutral, &lt;br /&gt;                    PublicKeyToken=null&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;column &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;AppUserID&lt;/span&gt;&amp;quot; &lt;span style=&quot;color: blue&quot;&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;many-to-many&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;bag&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h5&gt;AppUser.hbm.xml&lt;/h5&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;hibernate-mapping &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;xmlns&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;urn:nhibernate-mapping-2.2&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;default-access&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;property&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;auto-import&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;true&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;default-cascade&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;none&lt;/span&gt;&amp;quot; &lt;br /&gt;                   &lt;span style=&quot;color: red&quot;&gt;default-lazy&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;true&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt; …&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;bag &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;cascade&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;save-update&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style=&quot;color: red&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;Roles&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style=&quot;color: red&quot;&gt;table&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;AppUsersRoles&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;key&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;column &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;AppUserID&lt;/span&gt;&amp;quot; &lt;span style=&quot;color: blue&quot;&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;key&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;many-to-many &lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;VirtualAltNetRTM.Core.Role, &lt;br /&gt;          VirtualAltNetRTM.Core, &lt;br /&gt;          Version=1.0.0.0, &lt;br /&gt;          Culture=neutral, &lt;br /&gt;          PublicKeyToken=null&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;column &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&amp;quot;&lt;span style=&quot;color: blue&quot;&gt;RoleID&lt;/span&gt;&amp;quot; &lt;span style=&quot;color: blue&quot;&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;many-to-many&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;bag&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here is the Edit of a recently created user. Note the checked values for both roles that I added this user to. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibPCCQD7VlXxEol1GNRhlZei-cKPF3lLdtzyzSl-s-1-PcwMHmmvHvtockFIWyBztBgyFa13MjWZ4WncuoDfdv80ZzGZ_sxWY7cJckZduM_dDVRaX9NBWykIBmm2Y-6C63nAUqH7T9l3g/s1600-h/UserEdit1%5B4%5D.gif&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;UserEdit1&quot; border=&quot;0&quot; alt=&quot;UserEdit1&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLKRYC4rOgufYCs8qJhvCcaw8ire8yFJd_7GwbUgMV44RwiPAUlvS6IsdhSFS3VtuauCqVllHZZAyRfFjLwfJ-MXJdSQv8-Jl3dXJUHaNwb2nzBCw3tAzOMuKmwE6bJgEBg9pgZV6WWz0/?imgmax=800&quot; width=&quot;307&quot; height=&quot;290&quot; /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Remove the user from both roles.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHjIHtrE-zPjfWIYBIVjLY12EoZXMmxaE_Wu2lEWXE0IfZ5J-DogKxeqzDWXLKJXmoS3wQ7Ir0jeHF-FmaDX3hJ5w9IYyufNfYB77CHBD3dLgzBnoh330nyv34p8lBGLya5_5IyU3LyIA/s1600-h/UserEdit2%5B3%5D.gif&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;UserEdit2&quot; border=&quot;0&quot; alt=&quot;UserEdit2&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRk364xtxKVvQHFqQuxtittSOEeu2RS2Fo5F57L5ACsJ-NoKMvIWyC2N-QALW8ZF95_tsCQVZbNLDKqyUUMMERyC7Ek7ZRCYv8TXXsR0nhMpwJfbxpQ3nm93c7EKbEZ9PAv_P5OLyTTVE/?imgmax=800&quot; width=&quot;322&quot; height=&quot;250&quot; /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In the final post for this series I will show the front-end changes made to make this all come together. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Links&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a title=&quot;Converting to New Conventions with Fluent NHibernate 1.0&quot; href=&quot;http://wiki.fluentnhibernate.org/Converting_to_new_style_conventions&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Converting to New Conventions with Fluent NHibernate 1.0&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a title=&quot;Architectural overview of Horn&quot; href=&quot;http://thesoftwaresimpleton.blogspot.com/2009/03/horn-architecure-overview.html&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Architectural overview of Horn&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/2e8eea1542a5dddf/99f93fce7db36495#99f93fce7db36495&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Discussion on implementing M:M conventions from James Gregory&lt;/a&gt;&lt;/p&gt;  </description><link>http://legeronline.blogspot.com/2009/09/extending-sarp-architecture-with.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHK82OWEK0UlR4kEZ_B9cxuDt9CfA1KeaKNP8QAV1VTFltF9mGEi956SMzK72tAxQxF4fKV-uNkTeRZXv_xdjqrziM7qJaDvA-F7fQd-_eZhXTvhnqD1Dz_Ui9XP0WRuzUKCorJJ8DZpk/s72-c?imgmax=800" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-1790277793014094527</guid><pubDate>Thu, 10 Sep 2009 01:22:00 +0000</pubDate><atom:updated>2009-09-10T09:56:45.019-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">S#arp Architecture</category><category domain="http://www.blogger.com/atom/ns#">VirtualAltNet</category><title>VAN:S#arp Architecture Revisited – Advanced Techniques – November 4, 2009</title><description>&lt;h2&gt;Topic&lt;/h2&gt;  &lt;p&gt;&lt;a href=&quot;http://devlicio.us/blogs/billy_mccafferty/&quot;&gt;Billy McCafferty&lt;/a&gt; will join us once again on the heels of releasing Service Pack 1 for S#arp Architecture version 1. He will spend some time reviewing feature improvements, changes and add more context to the framework where time was not permitted in the first meeting. If you have any specific questions you would like addressed during the evening please add a question to our &lt;a href=&quot;http://groups.google.com/group/virtualaltnet&quot;&gt;group&lt;/a&gt; and we will make sure Billy is ready to answer it.&lt;/p&gt;  &lt;h2&gt;Bio&lt;/h2&gt;  &lt;p&gt;Who is and what makes this Billy McCafferty guy tick? Well he is a long time developer and a hopeless romantic when it comes to writing beautiful software. Billy currently leads a double life between helping to run the world&#39;s greatest IT training school at &lt;a href=&quot;http://www.itsamuraischool.com/&quot;&gt;http://www.itsamuraischool.com/&lt;/a&gt; and filling the part-time role of lead developer and architect with Parsons Brinckerhoff.  Billy is enjoying getting a bit of his life back after the recent release S#arp Architecture 1.0 and is currently hard at work on the first quarterly release later in September of 2009.&lt;/p&gt;  &lt;h2&gt;What is VAN? &lt;/h2&gt;  &lt;p&gt;Virtual &lt;a href=&quot;http://www.virtualaltnet.com/&quot; target=&quot;_blank&quot;&gt;ALT.NET&lt;/a&gt; (VAN) is the online gathering place of the &lt;a href=&quot;http://altdotnet.org/&quot; target=&quot;_blank&quot;&gt;ALT.NET&lt;/a&gt; community. Through conversations, presentations, pair programming and programming dojo’s, we strive to improve, explore, and challenge the way we create software. Using net conferencing technology such as Skype and LiveMeeting, we hold regular meetings, open to anyone, usually taking the form of a presentation or an Open Space Technology-style conversation. &lt;/p&gt;  &lt;p&gt;Please see the Calendar to find a VAN group that meets at a time   &lt;br /&gt;convenient to you, and feel welcome to join a meeting. Past sessions can be found on the Recording page. &lt;/p&gt;  &lt;p&gt;To stay informed about VAN activities, you can subscribe to the Virtual &lt;a href=&quot;http://groups.google.com/group/virtualaltnet?hl=en&quot; target=&quot;_blank&quot;&gt;ALT.NET&lt;/a&gt; (VAN) Google Group and follow the Virtual &lt;a href=&quot;http://virualaltnet.blogspot.com/&quot; target=&quot;_blank&quot;&gt;ALT.NET&lt;/a&gt; blog. &lt;/p&gt;  &lt;h4&gt;Meeting Details &lt;/h4&gt;  &lt;p&gt;Times below are Central Daylight Time   &lt;br /&gt;Start Time: Wed, November 4, 2009 8:00 PM UTC/GMT -5 hours    &lt;br /&gt;End Time: Wed, November 4, 2009 10:00 PM UTC/GMT -5 hours    &lt;br /&gt;Attendee URL: &lt;a href=&quot;http://www.virtualaltnet.com/&quot;&gt;Attend the meeting (Live Meeting)&lt;/a&gt;&lt;/p&gt;</description><link>http://legeronline.blogspot.com/2009/09/vansarp-architecture-revisited-advanced.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-3629631412539425465</guid><pubDate>Mon, 31 Aug 2009 00:00:00 +0000</pubDate><atom:updated>2009-09-01T19:25:11.578-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Fluent NHibernate</category><category domain="http://www.blogger.com/atom/ns#">NHibernate</category><category domain="http://www.blogger.com/atom/ns#">S#arp Architecture</category><title>S#arp Architecture – Part 1: Implementing the M:M mapping override</title><description>&lt;h2&gt;User Story&lt;/h2&gt;  &lt;p&gt;Should be able to add a user to more than one role. Should be able to remove the user from specific roles. &lt;/p&gt;  &lt;h2&gt; &lt;/h2&gt;    &lt;h2&gt;Convention over Configuration&lt;/h2&gt;  &lt;p&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;This topic is garnering quite a bit of interest of late in the .Net community. James Kovacs recently appeared on an episode of &lt;a title=&quot;Episode 475 with James Kovacs Convention over Configuration&quot; href=&quot;http://www.dotnetrocks.com/default.aspx?showNum=475&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;DotNetRocks&lt;/a&gt; rocks discussing Convention over Configuration. He spent a fair amount of time discussing the move from XML configuration for NHibernate by using the conventions of Fluent NHibernate.  By default S#arp Architecture implements the &lt;a title=&quot;Fluent NHibernate&quot; href=&quot;http://fluentnhibernate.org/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Fluent NHibernate&lt;/a&gt; auto-mapping convention. This means that you only need to alter the convention for various edge cases, one of those being M:M associations. Knowing in advance that you will need to perform the override is handy hence the reason for today’s discussion.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;Review of the Model&lt;/h2&gt;    &lt;p&gt;I have the following two entities forming a many-to-many relationship. &lt;/p&gt;&lt;h2&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibKEo3zQH0RtHsMynvTJy4cZr9yxWrCft_NNX3J4gq6hDV95LRN5mGougE04u2LwIakjt2QP657LB8La4EHsDxLt1nDyNX692NvKA7AAQIE9z-HQjllWMxinviFSPSwDASSHfkogra4BU/s1600-h/ClassDiagram1.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 154px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibKEo3zQH0RtHsMynvTJy4cZr9yxWrCft_NNX3J4gq6hDV95LRN5mGougE04u2LwIakjt2QP657LB8La4EHsDxLt1nDyNX692NvKA7AAQIE9z-HQjllWMxinviFSPSwDASSHfkogra4BU/s400/ClassDiagram1.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5375915805158884274&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;      &lt;p&gt; &lt;/p&gt;   &lt;h2&gt;Mapping Override using Class Auto Mapping&lt;/h2&gt;  &lt;p&gt;I created a sub-folder within my data assembly naming it NHibernateMaps and then proceeded to add the following two classes within it. I added using statements for Fluent NHibernate’s AutoMap and AutoMap Alteration namespaces. The key mapping attributes below for both sides of the relationship are the WithParentKeyColumn and WithChildKeyColumn values. &lt;/p&gt;  &lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;public class &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;AppUserMap &lt;/span&gt;: &lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;IAutoMappingOverride&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;AppUser&lt;/span&gt;&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color:blue;&quot;&gt;public void &lt;/span&gt;Override(&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;AutoMap&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;AppUser&lt;/span&gt;&amp;gt; mapping)&lt;br /&gt;{&lt;br /&gt;  mapping.Id(x =&amp;gt; x.Id, &lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;AppUserID&quot;&lt;/span&gt;)&lt;br /&gt;      .WithUnsavedValue(0)&lt;br /&gt;      .GeneratedBy.Identity();&lt;br /&gt;&lt;br /&gt;  mapping.WithTable(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;AppUsers&quot;&lt;/span&gt;);&lt;br /&gt;  mapping.SetAttribute(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;lazy&quot;&lt;/span&gt;, &lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;false&quot;&lt;/span&gt;);&lt;br /&gt;  mapping.Map(x =&amp;gt; x.LoginName).WithLengthOf(50);&lt;br /&gt;  mapping.Map(x =&amp;gt; x.Password).WithLengthOf(255);&lt;br /&gt;  mapping.HasManyToMany(x =&amp;gt; x.Roles)&lt;br /&gt;      .WithTableName(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;AppUserRoles&quot;&lt;/span&gt;)&lt;br /&gt;      .WithParentKeyColumn(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;AppUserID&quot;&lt;/span&gt;)&lt;br /&gt;      .WithChildKeyColumn(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;RoleID&quot;&lt;/span&gt;)&lt;br /&gt;      .AsBag();&lt;br /&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;public class &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;RoleMap &lt;/span&gt;: &lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;IAutoMappingOverride&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;Role&lt;/span&gt;&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color:blue;&quot;&gt;public void &lt;/span&gt;Override(&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;AutoMap&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;Role&lt;/span&gt;&amp;gt; mapping)&lt;br /&gt;{&lt;br /&gt;  mapping.Id(x =&amp;gt; x.Id, &lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;RoleID&quot;&lt;/span&gt;)&lt;br /&gt;      .WithUnsavedValue(0)&lt;br /&gt;      .GeneratedBy.Identity();&lt;br /&gt;&lt;br /&gt;  mapping.Map(x =&amp;gt; x.Name, &lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;RoleName&quot;&lt;/span&gt;);&lt;br /&gt;  mapping.SetAttribute(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;lazy&quot;&lt;/span&gt;,&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;false&quot;&lt;/span&gt;);&lt;br /&gt;  mapping.HasManyToMany&amp;lt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;AppUser&lt;/span&gt;&amp;gt;(x =&amp;gt; x.AppUsers)&lt;br /&gt;      .WithTableName(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;AppUserRoles&quot;&lt;/span&gt;)&lt;br /&gt;      .Inverse()&lt;br /&gt;      .WithParentKeyColumn(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;RoleID&quot;&lt;/span&gt;)&lt;br /&gt;      .WithChildKeyColumn(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;AppUserID&quot;&lt;/span&gt;)&lt;br /&gt;     .AsBag();&lt;br /&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;The choice of using a Bag, List, Set, Map or array structure to handle the transient collection in memory depends on the context of the requirement at hand. In our domain model above we are representing the User and Role associations as an IList structure that is equivalent to NHibernate’s IBag object and therefore we set the mapping to use a Bag. &lt;a title=&quot;Foundations of Programming - Part 6 - NHibernate&quot; href=&quot;http://codebetter.com/blogs/karlseguin/archive/2008/01/02/foundations-of-programming-part-6-nhibernate.aspx&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Karl Seguin&lt;/a&gt; who blogs over at CodeBetter.com discusses this point in the Relationships section in Part 6 of a great series of articles that formed his book called &lt;a title=&quot;Foundations of Programming&quot; href=&quot;http://codebetter.com/media/p/179694.aspx&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Foundations of Programming&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;In the next article I hope to implement the same override but by using the Conventional approach. Therefore there will not be any need to use any mapping classes. I will wrap up the series by indicating the additional changes needed in the UI and controller layers.&lt;/p&gt;</description><link>http://legeronline.blogspot.com/2009/08/sarp-architecture-part-1-implementing.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibKEo3zQH0RtHsMynvTJy4cZr9yxWrCft_NNX3J4gq6hDV95LRN5mGougE04u2LwIakjt2QP657LB8La4EHsDxLt1nDyNX692NvKA7AAQIE9z-HQjllWMxinviFSPSwDASSHfkogra4BU/s72-c/ClassDiagram1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-4885910753105587929</guid><pubDate>Sat, 29 Aug 2009 19:01:00 +0000</pubDate><atom:updated>2009-08-30T20:26:02.966-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MVC</category><category domain="http://www.blogger.com/atom/ns#">NHibernate</category><category domain="http://www.blogger.com/atom/ns#">S#arp Architecture</category><title>S#arp Architecture - Architectural review</title><description>&lt;p&gt; &lt;/p&gt;  &lt;h2&gt;Overview&lt;/h2&gt;  &lt;p&gt;For the past 6 months or so I have been using and following closely the &lt;a title=&quot;Code for S#harp Architecture&quot; href=&quot;http://code.google.com/p/sharp-architecture/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;S#arp Architecture&lt;/a&gt; framework’s evolution from beta to release. During this time I have found the project, community and reference documentation excellent! &lt;a title=&quot;Billy McCafferty on devlicio.us&quot; href=&quot;http://devlicio.us/blogs/billy_mccafferty/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Billy McCafferty&lt;/a&gt; and the team of contributors have done a professional job assembling this framework into a key source of guidance on how to assemble an enterprise architecture that embraces (from its Project main page on Google code) : &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Loose coupling leveraging Microsoft’s ASP.Net MVC &lt;/li&gt;    &lt;li&gt;Persistence ignorance with NHibernate &lt;/li&gt;    &lt;li&gt;Domain Driven Design &lt;/li&gt;    &lt;li&gt;Pre-configured infrastructure &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;S#arp Architecture includes S#arp Scaffolding that greatly speeds up the process of adding CRUD functionality for your entities through the use of T4 templates implemented with the T4 Template toolkit. The “out-of-the box” templates can be extended adding support for using the &lt;a title=&quot;Ext JS: Cross-Browser Rich Internet Application Framework&quot; href=&quot;http://extjs.com/products/extjs/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Ext-JS&lt;/a&gt; JavaScript library. It also includes a Visual Studio project template to build out your Solution tree. Billy has a good &lt;a title=&quot;S#arp Scaffolding with Ext JS&quot; href=&quot;http://devlicio.us/blogs/billy_mccafferty/archive/2009/04/29/s-arp-scaffolding-with-ext-js.aspx&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt; on the topic of extending the T4 template to embrace the EXT-JS library.He frequently responds to questions that come into the Google group discussion forum linked at the bottom of this post. &lt;a title=&quot;Coding Hillbilly&quot; href=&quot;http://kyle.baley.org/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Kyle Baley&lt;/a&gt; has done several &lt;a title=&quot;Kyle Baley on Dimecasts.Net&quot; href=&quot;http://www.dimecasts.net/Casts/ByAuthor/Kyle%20Baley&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Dimecast&lt;/a&gt; videos on getting started and extending the architecture. Others of note who contribute with insightful comments and blog entries that have helped my understanding are &lt;a title=&quot;Luis Abreu&#39;s over view on S#arp Architecture&quot; href=&quot;http://msmvps.com/blogs/luisabreu/archive/tags/S_2300_arp/default.aspx&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Luis Abreu&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;What follows will be a series of blog posts documenting the ability to override the default generated templates and code to produce the desired result of managing the roles for various users accessing an MVC website in the context of varying controller actions.&lt;/p&gt;  &lt;p&gt;The posts will be as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://legeronline.blogspot.com/2009/08/sarp-architecture-part-1-implementing.html&quot;&gt;Introducing the model and overriding Fluent NHibernate’s auto mapping strategy within S#arp  Architecture&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;  &lt;/p&gt;  &lt;h2&gt;Links&lt;/h2&gt;  &lt;p&gt;&lt;a title=&quot;S#arp Architecture trunk&quot; href=&quot;http://sharp-architecture.googlecode.com/svn/trunk&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;S#arp Architecture trunk&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title=&quot;Inspiration for the framework&quot; href=&quot;http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Origins of architecture&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title=&quot;Billy McCafferty on VAN&quot; href=&quot;http://www.viddler.com/explore/virtualaltnet/videos/25/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Billy McCafferty on VAN&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title=&quot;S#arp Architecture Google Group Discussions&quot; href=&quot;http://groups.google.com/group/sharp-architecture?hl=en&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Discussion group&lt;/a&gt;&lt;/p&gt;</description><link>http://legeronline.blogspot.com/2009/08/sarp-architecture-architectural-review.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-5181200837933415782</guid><pubDate>Thu, 23 Jul 2009 00:52:00 +0000</pubDate><atom:updated>2009-07-23T08:50:56.320-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">NH Prof</category><category domain="http://www.blogger.com/atom/ns#">NHibernate</category><category domain="http://www.blogger.com/atom/ns#">VirtualAltNet</category><title>VAN: Lessons learned building NH Profiler with Ayende Rahien, Christopher Bennage and Rob Eisenberg Oct 21 and Oct 28, 2009</title><description>&lt;h4&gt; &lt;/h4&gt;  &lt;h2&gt;Topic&lt;/h2&gt;  &lt;p&gt;A three way conversation with the main collaborators who created NH Profiler. This tool enables developers to gain a deeper insight into profiling their applications communication from NHibernate(.Net) and Hibernate(Java) through to the database.&lt;/p&gt;  &lt;h2&gt;Who they are&lt;/h2&gt;  &lt;p&gt;&lt;a title=&quot;Ayende&#39;s blog&quot; href=&quot;http://ayende.com/blog&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Ayende Rahien&lt;/a&gt; contributed efforts on the back-end development.&lt;/p&gt;  &lt;p&gt;&lt;a title=&quot;Bluespire&quot; href=&quot;http://www.bluespire.com/index.htm&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Chris Bennage and Rob Eisenberg&lt;/a&gt; contributed their efforts to the front-end.&lt;/p&gt;  &lt;h2&gt;Time and location of the meetings&lt;/h2&gt;  &lt;p&gt;Times below are Central Daylight Time &lt;br /&gt;Start Time: Oct 21 and 28, Each week 8:00 PM UTC/GMT -5 hours  &lt;br /&gt;End Time: Oct 21 and 28, Each week 10:00 PM UTC/GMT -5 hours  &lt;br /&gt;Attendee URL: &lt;a href=&quot;http://snipr.com/virtualaltnet%20&quot;&gt;Attend the meeting&lt;/a&gt; (Live Meeting)&lt;/p&gt;</description><link>http://legeronline.blogspot.com/2009/07/van-lessons-learned-building-nh.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-6861542987660886264</guid><pubDate>Wed, 15 Jul 2009 23:20:00 +0000</pubDate><atom:updated>2009-07-23T08:34:09.592-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Continuous Improvement</category><category domain="http://www.blogger.com/atom/ns#">Productivity</category><category domain="http://www.blogger.com/atom/ns#">VirtualAltNet</category><title>VAN: An evening with Scott Bellware discussing the myth of developer productivity August 18, 2009</title><description>&lt;h2&gt;Topic&lt;/h2&gt;  &lt;p&gt;&lt;a href=&quot;http://blog.scottbellware.com/2009/07/myth-of-developer-productivity.html&quot;&gt;The myth of developer productivity&lt;/a&gt;.&lt;/p&gt;  &lt;h2&gt;Scott’s Bio&lt;/h2&gt;  &lt;p&gt;&lt;a title=&quot;Scott&#39;s Blog&quot; href=&quot;http://blog.scottbellware.com/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Scott Bellware&lt;/a&gt; is a software product designer, developer, manager, and agile coach living in Austin, TX. He speaks at software industry conferences and teaches agile development practices and software production methodologies in workshops in the US, Canada, and Europe. He is the founder of the Lean Software Austin and the AgileATX communities of software practitioners. He is the organizer of the upcoming MonoSpace, ALT.NET Open Space, and Continuous Improvement conferences in Austin, and has served as the content chairman for the agile development track at the DevTeach conferences, as well as the chairman of the INETA Speaker Committee. He is the recipient of Microsoft&#39;s Most Valuable Professional award.&lt;/p&gt;  &lt;h2&gt;Meeting Details&lt;/h2&gt;  &lt;p&gt;Times below are expressed in Central Daylight Time &lt;/p&gt;  &lt;p&gt;Start Time: Wed, August 19, 2009 8:00 PM UTC/GMT -5 hours &lt;/p&gt;  &lt;p&gt;End Time: Wed, August 19, 2009 10:00 PM UTC/GMT -5 hours &lt;/p&gt;  &lt;p&gt;Attendee URL: &lt;a href=&quot;http://snipr.com/virtualaltnet&quot;&gt;http://snipr.com/virtualaltnet&lt;/a&gt; (Live Meeting) &lt;/p&gt;</description><link>http://legeronline.blogspot.com/2009/07/van-evening-with-scott-bellware.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-1614582907478266772</guid><pubDate>Wed, 15 Jul 2009 22:29:00 +0000</pubDate><atom:updated>2009-07-23T08:36:25.972-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DDD</category><category domain="http://www.blogger.com/atom/ns#">Open Spaces</category><category domain="http://www.blogger.com/atom/ns#">VirtualAltNet</category><title>VAN: An evening of Questions and Sharing of group opinions regarding DDD pragmatic concepts facilitated by David Laribee July 29, 2009</title><description>&lt;h2&gt;Topic&lt;/h2&gt; In the spirit of Open Spaces we will be bringing in &lt;a title=&quot;Dave Laribee&#39;s Blog&quot; href=&quot;http://thebeelog.com/&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;David Laribee&lt;/a&gt; to facilitate a discussion of opinions on Domain Driven Design.   &lt;h2&gt;Who is Dave?&lt;/h2&gt; He is a coach for the product development team at VersionOne. He has 12 years experience designing and developing enterprise applications and coaching Agile teams. David has worked on internal IT, product development, consulting, and rapid prototyping teams across a wide variety of industries. David is a frequent speaker at local and national developer events. He was awarded a Microsoft Architecture MVP for 2007 and 2008 and writes about Agile and Lean methods, coaching, and software design on the CodeBetter blog network.   &lt;h2&gt;Meeting Details&lt;/h2&gt; Times below are Central Daylight Time&lt;br /&gt;Start Time: Wed, July 29, 2009 8:00 PM UTC/GMT -5 hours&lt;br /&gt;End Time: Wed, July 29, 2009 10:00 PM UTC/GMT -5 hours&lt;br /&gt;Attendee URL: &lt;a title=&quot;Virtual AltNet Live Meeting&quot; href=&quot;http://snipr.com/virtualaltnet%20&quot; rel=&quot;tag&quot; target=&quot;_blank&quot;&gt;Attend the meeting&lt;/a&gt; (Live Meeting)&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;margin: 0px; padding: 0px; display: inline; float: none;&quot; id=&quot;scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9c57f5b8-8752-4049-8e63-a6b0103874c5&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt;del.icio.us Tags: &lt;a href=&quot;http://del.icio.us/popular/DDD&quot; rel=&quot;tag&quot;&gt;DDD&lt;/a&gt;,&lt;a href=&quot;http://del.icio.us/popular/Open+Spaces&quot; rel=&quot;tag&quot;&gt;Open Spaces&lt;/a&gt;,&lt;a href=&quot;http://del.icio.us/popular/VirtualAltNet&quot; rel=&quot;tag&quot;&gt;VirtualAltNet&lt;/a&gt;&lt;/div&gt;  &lt;div style=&quot;margin: 0px; padding: 0px; display: inline; float: none;&quot; id=&quot;scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8cd058f6-02ab-4faf-8dae-f956ad8cc226&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt;&lt;br /&gt;Technorati Tags: &lt;a href=&quot;http://technorati.com/tags/DDD&quot; rel=&quot;tag&quot;&gt;DDD&lt;/a&gt;,&lt;a href=&quot;http://technorati.com/tags/Open+Spaces&quot; rel=&quot;tag&quot;&gt;Open Spaces&lt;/a&gt;,&lt;a href=&quot;http://technorati.com/tags/VirtualAltNet&quot; rel=&quot;tag&quot;&gt;VirtualAltNet&lt;/a&gt;&lt;/div&gt;</description><link>http://legeronline.blogspot.com/2009/07/van-evening-of-questions-and-sharing-of.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-4002418881099490760</guid><pubDate>Fri, 22 May 2009 19:46:00 +0000</pubDate><atom:updated>2009-05-22T17:53:32.838-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Active Directory</category><category domain="http://www.blogger.com/atom/ns#">Kerberos</category><category domain="http://www.blogger.com/atom/ns#">SSAS 2005</category><title>Enabling Kerberos delegation with Application Service Architectures and SQL Server Analysis Services 2005</title><description>&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;This document describes how to setup Kerberos delegation to authenticate an application windows service HTTP requests to SQL Server Analysis Services 2005. Additionally the steps for configuration that will follow become required when the application host machines are separated but exist within the same domain. More information can be obtained on this &lt;a title=&quot;Kerberos Delegation&quot; href=&quot;http://www.mosha.com/msolap/articles/kerberos_delegation.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Active Directory Setup&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;When making changes in Active Directory there is a requirement for you to have a System Administrator with permissions to invoke any of the changes needed below. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;● The server which hosts your application windows services must be set to &#39;Trust this computer for Delegation (Kerberos&lt;br /&gt;only)&#39;.&lt;br /&gt;● All your AD user-accounts that will utilize your application windows service should have the setting &quot;Sensitive: not allowed&lt;br /&gt;to be delegated&quot; disabled. This means that all these accounts should be allowed to be delegated.&lt;br /&gt;● Register the Service Principal Names (SPN) described in this document in your Active Directory.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Service Principal Name Registration&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;If you do not have the Service Principal Name tool or SPN tool is part of the Windows Server 2003 and 2008 Support tools and can be found on your product CD. Alternatively you can download it from &lt;a title=&quot;Windows Server Support Tools&quot; href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyID=96a35011-fd83-419d-939b-9a772ea2df90&amp;amp;DisplayLang=en&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Machine hosting your application windows service.&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;Check the registered SPN’s before you continue with the registration by issuing the following text from the command line:&lt;br /&gt;&lt;em&gt;&lt;strong&gt;setspn –l &amp;lt;domainName]\[serverHostName]&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;This command will list (-l) out the current SPN’s and the only one’s that should show up are as follows:&lt;/p&gt;&lt;/blockquote&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;HOST/&amp;lt;serverHostName&amp;gt;&lt;br /&gt;HOST/&amp;lt;serverHostName&amp;gt;.domain.com&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;&lt;strong&gt;Protocol registration&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;setspn –a HTTP/&amp;lt;domainName&amp;gt;\&amp;lt;serverHostName&amp;gt; &amp;lt;serviceAccount&amp;gt;&lt;br /&gt;setspn –a HTTP/&amp;lt;serverHostName&amp;gt;.&amp;lt;domainName&amp;gt;.com &amp;lt;serviceAccount&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;&lt;strong&gt;Application Service registration&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;setspn –a &amp;lt;appWindowsServiceName&amp;gt;/&amp;lt;domainName&amp;gt;\&amp;lt;serverHostName&amp;gt; &amp;lt;serviceAccount&amp;gt;&lt;br /&gt;setspn –a &amp;lt;appWindowsServiceName&amp;gt;/&amp;lt;serverHostName&amp;gt;.&amp;lt;domainName&amp;gt;.com &amp;lt;serviceAccount&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;&lt;em&gt;Note: The &amp;lt;serviceAccount&amp;gt; token we have used above will be referenced as the &amp;lt;serverHostName&amp;gt; token when the services are running as LocalSystem/NetworkService. Otherwise specify the Domain account that the services are running under.&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Machine Hosting SQL Server Analysis Services&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;Check the registered SPN’s before you continue with the registration by issuing the following text from the command line:&lt;br /&gt;&lt;em&gt;&lt;strong&gt;setspn –l &amp;lt;domainName]\[serverHostName]&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;This command will list (-l) out the registered SPN’s. Typically the one’s that will appear are the same as noted above on your Application windows service machine.&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p align=&quot;left&quot;&gt;&lt;strong&gt;SSAS Service registration&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;setspn –a MSOLAPSvc.3/&amp;lt;domainName&amp;gt;\&amp;lt;serverHostName&amp;gt; &amp;lt;serviceAccount&amp;gt;&lt;br /&gt;setspn –a MSOLAPSvc.3/&amp;lt;serverHostName&amp;gt;.&amp;lt;domainName&amp;gt;.com &amp;lt;serviceAccount&amp;gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The &amp;lt;serviceAccount&amp;gt; token notes above equally apply.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Setup the clients&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;● The URL used to connect to the Application service web application &lt;a href=&quot;http://&amp;lt;serverhostname&amp;gt;.&amp;lt;domainname&amp;gt;.com/&quot;&gt;http://&amp;lt;serverhostname&amp;gt;.&amp;lt;domainname&amp;gt;.com/&lt;/a&gt;) should be added to the trusted sites list in Internet Explorer&lt;br /&gt;● To use Windows Integrated Authentication, the option ‘Automatic logon with current username and&lt;br /&gt;password’ must be selected in the Security settings dialog box for the trusted sites zone, (Section:User authentication -Logon) &lt;/p&gt;</description><link>http://legeronline.blogspot.com/2009/05/enabling-kerberos-delegation-with.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-5205935450486953356</guid><pubDate>Sun, 03 May 2009 04:10:00 +0000</pubDate><atom:updated>2009-05-05T11:22:34.524-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Continuous Integration</category><category domain="http://www.blogger.com/atom/ns#">Nant</category><category domain="http://www.blogger.com/atom/ns#">NUnit</category><category domain="http://www.blogger.com/atom/ns#">Team City</category><title>Team City Addin for NUnit</title><description>Recently at our &lt;a href=&quot;http://www.viddler.com/explore/virtualaltnet/videos/22/&quot;&gt;Virtual Alt.Net&lt;/a&gt; group I ran through getting a basic project up and running within Team City 4.0. During the demonstration we were lucky to have a couple of key insiders from Jet Brains join us in the discussion. During the presentation I was painfully hitting the proverbial brick wall of &quot;fail&quot;, namely around getting my NUnit test results integrated into Team City&#39;s build reports.  To save all of you from having to watch the video and to concisely put this rather simple issue to rest quickly, I have concluded at the bottom of this post steps requiring action to have your NUnit tests integrated within Team City. I would like to thank &lt;a href=&quot;http://www.jetbrains.net/confluence/display/~yaegor&quot;&gt;&lt;span id=&quot;title-text&quot;&gt;Yegor Yarko&lt;/span&gt;&lt;/a&gt; and Eugene Petrenko and all participating attendees who offered their assistance in getting this to work!&lt;br /&gt;&lt;br /&gt;In order to integrate the NUnit Test runner, Team City requires a bit of additional configuration and the documentation is not as forthcoming as I would like. Hopefully this post will assist others who want to integrate their testing statistics into their build server&#39;s dashboard reporting.&lt;br /&gt;&lt;br /&gt;Jet Brains &lt;a href=&quot;http://www.jetbrains.net/confluence/display/TCD4/TeamCity+Addin+for+NUnit&quot;&gt;indicates&lt;/a&gt; that they provide support for NU&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6NyoM2oZ9gmGWpTBdGhSb1ijQaGte5A9myj07xaWvagZj0QU1-ctILmXakiZ4SGp9T1aZ2JtiRpCHUTXT2x9_EkeCmUl_fViXJbxF6kttij_ZBnKabPRctzdqTD293VqnEop_mGFXr6M/s1600-h/TC1.JPG&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 77px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6NyoM2oZ9gmGWpTBdGhSb1ijQaGte5A9myj07xaWvagZj0QU1-ctILmXakiZ4SGp9T1aZ2JtiRpCHUTXT2x9_EkeCmUl_fViXJbxF6kttij_ZBnKabPRctzdqTD293VqnEop_mGFXr6M/s400/TC1.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5332142832766681890&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;nit via an addin. The addin provides on-the-fly test coverage reporting integrated within Team City.&lt;br /&gt;The screen to the left appears as an additional chart located within the Settings tab indicating Test Count.&lt;br /&gt;&lt;br /&gt;The screen shot below is indicative proof that test reports are not configured correctly. The build itself however is successful.  Notice that there are four tabs displayed, there should be five with a Tab named Tests.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgePazLYmgXJDPK5qlvhv5zcA7NmLEAf-nQFIpl0-3-LIqgp2QXOWNTgup-OTTwEnojo9FNJSYyaAfGejw3dHPcvy4sBeIKYTQAPYYe7fOoHS-aVzTZYcAWK7_3aG7P6DHZEoLPFIJr_3I/s1600-h/TC2.JPG&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 94px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgePazLYmgXJDPK5qlvhv5zcA7NmLEAf-nQFIpl0-3-LIqgp2QXOWNTgup-OTTwEnojo9FNJSYyaAfGejw3dHPcvy4sBeIKYTQAPYYe7fOoHS-aVzTZYcAWK7_3aG7P6DHZEoLPFIJr_3I/s400/TC2.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5331624286007171634&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When the NUnit test runner integration is correct the screen will appear as follows:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr6TEGvljeL9zO0fqhiwggDk6snZRAwr5GdHobb4ciXUNW9XiQG6JTZiItlFH5k6_7dlxmMnPZ3_7kphhiQS_69zaQ0mpP12HHqis6dUxxpzw1He3TOiGN6ItwJHELHiGLDrN-L8KE0N0/s1600-h/TC3.JPG&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 174px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr6TEGvljeL9zO0fqhiwggDk6snZRAwr5GdHobb4ciXUNW9XiQG6JTZiItlFH5k6_7dlxmMnPZ3_7kphhiQS_69zaQ0mpP12HHqis6dUxxpzw1He3TOiGN6ItwJHELHiGLDrN-L8KE0N0/s400/TC3.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5331625575794385026&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Click on the Tests tab and you can filter the tests by ignored, successful, failed, or all. Additionally you can view your tests by classes, suites, namespaces/packages, or all. This filtering capability is directly above the listing of tests in the screenshot below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDRV2eds_suYkaAmURESOQSJruVxa-1NNAug9DTRKBQCm2RVFMghSbROXyUjB_MnUhyphenhyphen6NVV8U2a0CjyZFZPLwM6Isnnlu8u10izaTX2ZkUNcg81AatO5lFBGbZdAUhQviMybMg1X_ZGes/s1600-h/TC4.JPG&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 93px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDRV2eds_suYkaAmURESOQSJruVxa-1NNAug9DTRKBQCm2RVFMghSbROXyUjB_MnUhyphenhyphen6NVV8U2a0CjyZFZPLwM6Isnnlu8u10izaTX2ZkUNcg81AatO5lFBGbZdAUhQviMybMg1X_ZGes/s400/TC4.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5331627399619818930&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Configuration Steps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is important to note that with the ensuing steps integration of the NUnit test runner is supported only from versions 2.4X and higher of NUnit.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Locate the &lt;span style=&quot;font-style: italic;&quot;&gt;nunit.console.exe.config&lt;/span&gt; file for the version of NUnit that you will be using. In this case I chose to use NUnit 2.4.8. The path to the file is &lt;span style=&quot;font-style: italic;&quot;&gt;C:\Program Files\NUnit 2.4.8\bin. &lt;/span&gt;Add the following XML to the config file save and close the file.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqh5uCVpyoJsFoHgL3HfK5bH2Yw2Lpoij0CXX_Xve2q3bVnZba9uWkKEruNpGV8tKY-Nde82O2TemFgfOC9fzWbSjxXNDPMtWqqJqx-ycI9olNHUHj_qp7EZmaJdiP28aCsgXOid1tszk/s1600-h/TC4.JPG&quot;&gt;&lt;img style=&quot;cursor: pointer; width: 400px; height: 68px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqh5uCVpyoJsFoHgL3HfK5bH2Yw2Lpoij0CXX_Xve2q3bVnZba9uWkKEruNpGV8tKY-Nde82O2TemFgfOC9fzWbSjxXNDPMtWqqJqx-ycI9olNHUHj_qp7EZmaJdiP28aCsgXOid1tszk/s400/TC4.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5332019673625249234&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;I defined a property for locating the NUnit console runner for version 2.4.8. This is optional of course I just find this a cleaner approach as I can reference this location with less noise later in the build script. Additionally its also worth noting that the version for NUnit&#39;s console runner does not have to match the version of NUnit referenced within your project&#39;s test assembly.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCSi3pBRepDlEAX2aj8SeNQXP9Uj4ovkdZXkli54iIXsGVj7ZSZsxxdfMN7EnhK9eHeFZ_1GKW1IoIXX7go457_qZSv6t0t_iegDYwU3QpJiXms3gKlH3rD_VfaxArfK0cmPfuBitjl6o/s1600-h/TC4.JPG&quot;&gt;&lt;img style=&quot;cursor: pointer; width: 400px; height: 12px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCSi3pBRepDlEAX2aj8SeNQXP9Uj4ovkdZXkli54iIXsGVj7ZSZsxxdfMN7EnhK9eHeFZ_1GKW1IoIXX7go457_qZSv6t0t_iegDYwU3QpJiXms3gKlH3rD_VfaxArfK0cmPfuBitjl6o/s400/TC4.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5332020663978281650&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Copy the dll and pdb files for the Team City Nunit AddIn to the location defined above for the nunintconsole property and place the files within the newly defined directory of addins that is created within this task. Then the tests are executed by NUnit.&lt;/li&gt;&lt;/ul&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyIs3hgOizfQbqluGlfs6mVugg5Et0us1ZgDKJD02MV_N3mZqvAha_GmmDQush25wrtQIX2HoEL8dbEM0n1ZpIU2j0GCubjhxHOg7UljoZh_jseDsSnqRJNc84DmXXxH-rwnfu_OOpTW4/s1600-h/TC4.JPG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 66px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyIs3hgOizfQbqluGlfs6mVugg5Et0us1ZgDKJD02MV_N3mZqvAha_GmmDQush25wrtQIX2HoEL8dbEM0n1ZpIU2j0GCubjhxHOg7UljoZh_jseDsSnqRJNc84DmXXxH-rwnfu_OOpTW4/s400/TC4.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5332023925667406642&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;The Team City test runner for NUnit will work only for version&#39;s 2.4x and higher for NUnit. If anyone has some alternative configuration that has worked for them I would love to hear them.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://legeronline.blogspot.com/2009/05/team-city-addin-for-nunit.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6NyoM2oZ9gmGWpTBdGhSb1ijQaGte5A9myj07xaWvagZj0QU1-ctILmXakiZ4SGp9T1aZ2JtiRpCHUTXT2x9_EkeCmUl_fViXJbxF6kttij_ZBnKabPRctzdqTD293VqnEop_mGFXr6M/s72-c/TC1.JPG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-6246419709825137827</guid><pubDate>Fri, 10 Apr 2009 19:17:00 +0000</pubDate><atom:updated>2009-04-19T19:25:16.140-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Build script</category><category domain="http://www.blogger.com/atom/ns#">Documentation</category><category domain="http://www.blogger.com/atom/ns#">Nant</category><category domain="http://www.blogger.com/atom/ns#">Visual Studio</category><title>Tricks for dealing with Assembly changes in DocProject</title><description>&lt;div&gt;I have been working with &lt;a href=&quot;http://unhandled-exceptions.com/blog/&quot; rel=&quot;friend colleague&quot;&gt;Steve Bohlen&lt;/a&gt; of late in evaluating a couple of API documentation engines that are being considered for inclusion with NHibernate&#39;s API.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One issue that was bothering me was how to best deal with detecting assembly changes in a Project. As many of you know NHibernate has a rather extensive API that undergoes many regular changes and additions. &lt;a href=&quot;http://www.codeplex.com/DocProject&quot;&gt;DocProject &lt;/a&gt;is one tool that is being evaluated to perform the documentation requirements. During the initial project setup a wizard prompt requests you to select your assembly targets for inclusion. These assemblies then appear as reference dependency inside of your DocProject project. So the question that was bothering me was what happens if you create new assemblies? Having to manually added these new assemblies to DocProject would become a nuisance as it would be easy to forget to do this step. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Stephen suggested the following which worked quite nice!&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;Step 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Remove the reference assemblies from DocProject&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglA5jDhXxW2I181l8JpB3imC5mIiT2ZVVrAKQy0AKWRBAKdR_iRxMJI79yzH8zCblS3gfw1jSI8RwgPee9d0SwDHYyThBiRqjORlLlJDH-DNiXQQd5qSNjDmIiyRVD4sPu37sg849tTk4/s320/CropperCapture%5B2%5D.Png&quot; style=&quot;cursor:pointer; cursor:hand;width: 250px; height: 320px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5323149640712969634&quot; /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After removing the dependencies, you need to specify an external location where they can be located by DocProject.  Below this is done within the DocProject Properties window supply we supply the External sources location for the source of the assemblies and the XML documentation files. &lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfG9rE1OR5-ODS2JJLyBUhpkIb4sqJZY-dbKuXO_N-VVL_hQVr9uX9-lfYl6hdK1QLU2c1KeE-xbryy1tLYqvs4uJzElEdQG78FqnjXpI62WL5A_afcZ_QVdJn2ygFKgN6YFFDNNrUfaY/s400/CropperCapture%5B6%5D.Png&quot; style=&quot;cursor:pointer; cursor:hand;width: 400px; height: 137px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5323232185613251554&quot; /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;Step 2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Create a post build event that copies the Assemblies to the projects output directory which in this case we have created a folder output target called Help. This folder content is also automatically cleaned and scrubbed by the projects build script during the compile task. We added the following macro command in the Project Properties | Build Events section defining a post-build event.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzGD6CS8veaOtIpn5OU4gOxCyW1fQb7n9rBtO9W3WQIciJL9rzylSFpguLJh_5M9MUY-qxhGnoleyQzGygzOjlLZyRQ0aHI7S8zTKXjJWWcmst1bxuXu6byowvVTG_9HhmuGlIhx332AM/s320/CropperCapture%5B4%5D.Png&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 166px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5323152907141517218&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Checking the noted changes caused a fail to the build. We need to automate the creation of the Help folder.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hence I added a make directory task to my compile target in the project&#39;s build script.&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsEB5MNDhejMeVnCDoEAoDcQSzpNwJYtNL_GJ2Ip-X6i90fBXMb2nT-AupNkSHELy5the4BbSlOQJgO7CTf0M-QAFbsNj9KMouJWe6404E653aBETOSCFxgR1YY-RSDLb_QAFR7qRkRyQ/s320/CropperCapture%5B5%5D.Png&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 78px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5323165622551811026&quot; /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now any assemblies newly added within my projects namespace will be automatically detected for documentation. The post-build task can be tweaked to limit the project assemblies you would like to document. &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;</description><link>http://legeronline.blogspot.com/2009/04/tricks-for-dealing-with-assembly.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglA5jDhXxW2I181l8JpB3imC5mIiT2ZVVrAKQy0AKWRBAKdR_iRxMJI79yzH8zCblS3gfw1jSI8RwgPee9d0SwDHYyThBiRqjORlLlJDH-DNiXQQd5qSNjDmIiyRVD4sPu37sg849tTk4/s72-c/CropperCapture%5B2%5D.Png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-7136522357731875970</guid><pubDate>Fri, 10 Apr 2009 18:20:00 +0000</pubDate><atom:updated>2009-04-10T16:47:09.790-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Documentation</category><category domain="http://www.blogger.com/atom/ns#">Subversion</category><category domain="http://www.blogger.com/atom/ns#">Team City</category><title>DocProject fails to build when checked into Subversion</title><description>&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;I found this error condition occurring after introducing a &lt;/span&gt;&lt;a href=&quot;http://www.codeplex.com/DocProject&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;documentation project&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; to my code project and checking this into source control. When the build server attempts to build the solution from source control the following error occurs:&lt;/span&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwZT_lkc9wWewKsBKXMOs_W-zH95RsGg1JrVvrIU3dkA9k1JS-nAO6AErNgj90xyTFsyV3KvccYJWLYg01YWJxyAd4XkoqnquX3Nr9-GE6nQDZ_h7LOmY7-tdu8AyqUlAs8uMj-UkXVJc/s400/DocProjErrorInTC.Png&quot; style=&quot;float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 400px; height: 123px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5323134093343247554&quot; /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;The actual error message is:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;li class=&quot;compiler-error&quot; style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;C:\Program Files\Dave  Sexton\DocProject\bin\DaveSexton.DocProject.targets(40, 5): Access to the path  &#39;all-wcprops&#39; is denied. &lt;/span&gt;&lt;/li&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;Its resolved by ignoring the build output folders for DocProject from being included as source control content.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;Namely ignore the following folders:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;buildhelp&lt;/span&gt;&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;, &lt;/span&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;Help\Html&lt;/span&gt;&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; and &lt;/span&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;Help\Html2&lt;/span&gt;&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: italic;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;Now the build is green once again and life is good!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjvd4iQrCfKpmq_cZxQLlwnLxG-R7BdED4BH5Ah1wtB72X0T4kECYAiSZJKufF6AsxZEntnVZ0PmNPVq3s93Xgn9I1E8Nzt0sMI-r4zGzLs0JInJrNWJkSEzWibVVD29Cc956tuuuq2to/s400/CropperCapture%5B1%5D.Png&quot; style=&quot;cursor:pointer; cursor:hand;width: 400px; height: 93px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5323142080209105202&quot; /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana;&quot;&gt;Over &lt;a href=&quot;http://www.codeplex.com/DocProject/Thread/View.aspx?ThreadId=20497&quot;&gt;here &lt;/a&gt;I found assistance to fix this issue&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://legeronline.blogspot.com/2009/04/docproject-fails-to-build-when-checked.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwZT_lkc9wWewKsBKXMOs_W-zH95RsGg1JrVvrIU3dkA9k1JS-nAO6AErNgj90xyTFsyV3KvccYJWLYg01YWJxyAd4XkoqnquX3Nr9-GE6nQDZ_h7LOmY7-tdu8AyqUlAs8uMj-UkXVJc/s72-c/DocProjErrorInTC.Png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-2748019318118254485</guid><pubDate>Sun, 15 Mar 2009 13:02:00 +0000</pubDate><atom:updated>2009-03-15T12:13:07.273-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">NHibernate</category><category domain="http://www.blogger.com/atom/ns#">SQL Query cache optimization</category><category domain="http://www.blogger.com/atom/ns#">SQL Server 2008</category><title>Solving slow parameterized query plans with SQL Server</title><description>This morning I was listening to &lt;a href=&quot;http://blog.stackoverflow.com/2009/03/podcast-45/&quot;&gt;Stack Overflow podcast#45&lt;/a&gt; in which &lt;a href=&quot;http://www.codinghorror.com/blog/&quot;&gt;Jeff Atwood&lt;/a&gt; indicated he had uncovered situations involving poor performing parametrized query&#39;s. The solution involves &lt;a href=&quot;http://blogs.msdn.com/sqlprogrammability/archive/2008/11/26/optimize-for-unknown-a-little-known-sql-server-2008-feature.aspx&quot;&gt;optimizing for &#39;UNKNOWN&#39;&lt;/a&gt; as an optional hint when dealing with parametrized queries.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-size:13;&quot; &gt;&lt;span style=&quot;font-family:Calibri;&quot;&gt;@p1=1, @p2=9998,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:&#39;Courier New&#39;;font-size:10;color:blue;&quot;   &gt;Select&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-family:&#39;Courier New&#39;;font-size:10;&quot;  &gt;  &lt;span style=&quot;color:gray;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;from&lt;/span&gt; t &lt;span style=&quot;color:blue;&quot;&gt;where&lt;/span&gt; col &lt;span style=&quot;color:gray;&quot;&gt;&gt;&lt;/span&gt; @p1  &lt;span style=&quot;color:gray;&quot;&gt;or&lt;/span&gt; col2 &lt;span style=&quot;color:gray;&quot;&gt;&gt;&lt;/span&gt;  @p2 &lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-family:&#39;Courier New&#39;;font-size:10;&quot;  &gt;&lt;span style=&quot;color:blue;&quot;&gt;order by&lt;/span&gt; col1 &lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:&#39;Courier New&#39;;font-size:10;&quot;  &gt;option  (OPTIMIZE &lt;span style=&quot;color:blue;&quot;&gt;FOR &lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;(&lt;/span&gt;@p1 &lt;b style=&quot;&quot;&gt;&lt;span style=&quot;color:red;&quot;&gt;UNKNOWN&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color:gray;&quot;&gt;,&lt;/span&gt; @p2 &lt;b style=&quot;&quot;&gt;&lt;span style=&quot;color:red;&quot;&gt;UNKNOWN&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color:gray;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;This optional optimization is available for SQL 2008 only. The option forces the query optimizer to look at all available statistical data to come up with a more intelligent deterministic view of what values the local variables used to generate the query plan should equate to rather than using the parameters being passed in by the application.  The workaround alternatives do not really offer any good alternatives to solve this issue most notably when dealing with dynamic parameters.&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt; font-weight: bold;&quot;&gt;Workarounds&lt;/p&gt;&lt;ol&gt;&lt;li&gt;  &lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:Symbol;font-size:13;&quot;  &gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:&#39;Times New Roman&#39;;font-size:7;&quot;  &gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:13;&quot; &gt;&lt;span style=&quot;font-family:Calibri;&quot;&gt;Recompile every time the query is executed using the RECOMPILE hint  - This can be very CPU intensive and effectively eliminates the benefits of  caching query plans. ex. option(RECOMPILE)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:Symbol;font-size:13;&quot;  &gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:&#39;Times New Roman&#39;;font-size:7;&quot;  &gt;  Un-p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:13;&quot; &gt;&lt;span style=&quot;font-family:Calibri;&quot;&gt;arametrize the query – Not a viable option in most cases due to  SQL injection risk.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:Symbol;font-size:13;&quot;  &gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:&#39;Times New Roman&#39;;font-size:7;&quot;  &gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:Symbol;font-size:13;&quot;  &gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:&#39;Times New Roman&#39;;font-size:7;&quot;  &gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:13;&quot; &gt;&lt;span style=&quot;font-family:Calibri;&quot;&gt;Hint with specific parameters using the OPTIMIZE FOR hint (However,  what value(s) should the app developer use?) This is a great option if the  values in the rows are static, that is; not growing in number, etc. – However in  my case the rows were not static.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:Symbol;font-size:13;&quot;  &gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:&#39;Times New Roman&#39;;font-size:7;&quot;  &gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:Symbol;font-size:13;&quot;  &gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:&#39;Times New Roman&#39;;font-size:7;&quot;  &gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:13;&quot; &gt;&lt;span style=&quot;font-family:Calibri;&quot;&gt;Forcing the use of a specific index&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt;&lt;p class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0in 0in 10pt 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;line-height: 115%;font-family:Symbol;font-size:13;&quot;  &gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:&#39;Times New Roman&#39;;font-size:7;&quot;  &gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:13;&quot; &gt;&lt;span style=&quot;font-family:Calibri;&quot;&gt;Use a plan guide – Using any of the recommendations  above.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Implications with NHibernate or other Object Relational Mappers&#39;s&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I am a user of NHibernate. At present NHibernate does not provide support for the SQL  2008 dialect and recommends using the SQL 2005 dialect configuration option to deal with SQL 2008 data sources. I am wondering if anyone in the NHibernate community has come  across this issue with slow parametrized SQL? Is this an issue that an ORM needs to be aware of when supporting a given database dialect? My view is yes. However I am still somewhat of a newb with NHibernate.&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;line-height: 115%;font-family:&#39;Courier New&#39;;font-size:10;&quot;  &gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;line-height: 115%;font-family:&#39;Courier New&#39;;font-size:10;&quot;  &gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description><link>http://legeronline.blogspot.com/2009/03/evils-of-slow-paramaterized-query-plans.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-5363886738531403022</guid><pubDate>Sat, 15 Nov 2008 03:08:00 +0000</pubDate><atom:updated>2008-11-17T20:52:29.974-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Certificate Errors</category><category domain="http://www.blogger.com/atom/ns#">SSL Errors</category><title>Catch SSL Certificate errors from HttpContext Request</title><description>A recent task was to try and redirect user entry points to an address that our web site&#39;s SSL certificate had been assigned to. An example follows to illustrate the problem.&lt;br /&gt;&lt;br /&gt;User wants to get to a secured page quickly without going through the site&#39;s internal navigation links. From the browser&#39;s Address bar they enter https://example.com/accounts/ and the Certificate returns an error code that when looked up indicates: &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;blockquote&gt;Error code: ssl error bad cert domain&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The certificate was issued to &lt;strong&gt;www.example.com&lt;/strong&gt; and indicates that &lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;example&lt;/span&gt;&lt;strong&gt;.com&lt;/strong&gt; uses an invalid security certificate.&lt;/p&gt;I was hoping to be able to catch the request in the Application_BeginRequest event but the SSL error occurs before this. The only way that the Application_BeginRequest event is invoked is when the user clicks through the certificate error message to Proceed Anyway.&lt;br /&gt;Here is an image of what to expect in Google Chrome.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOiU383gt6VO4ErK809A-C4Cx3Gl06EIO3tpthKZd4cQosYotD_JzkY4WQy5jmu1mf7qUA8BuSm9ToJUrZGkvhd7oEKKyTV2-ilbv1jQl4_48qeG_g99fRZpf9yvG0kHaQfVQY-OfCt0U/s1600-h/SSLCertError.gif&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5268724837007118226&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 141px; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOiU383gt6VO4ErK809A-C4Cx3Gl06EIO3tpthKZd4cQosYotD_JzkY4WQy5jmu1mf7qUA8BuSm9ToJUrZGkvhd7oEKKyTV2-ilbv1jQl4_48qeG_g99fRZpf9yvG0kHaQfVQY-OfCt0U/s400/SSLCertError.gif&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;The solution to this is simple but many System Admins prefer to have Dev implement a band-aid solution of redirecting traffic from the typical landing page. In other words look for a host request from example.com and redirect to &lt;a href=&quot;http://www.example.com/&quot;&gt;http://www.example.com/&lt;/a&gt; &lt;strong&gt;The true solution is to fix the certificate!&lt;/strong&gt; Contact your SSL certificate provider and have them re-issue a certificate that includes a SubjectAlternativeName (SAN) entry. In our example this means theat traffic coming from either example.com or &lt;a href=&quot;http://www.example.com/&quot;&gt;www.example.com&lt;/a&gt; would be correctly named and known to the certificate. In most cases the certificate authority&#39;s will do this at no additional cost. Lesson&#39;s learned!&lt;br /&gt;&lt;br /&gt;In researching this issue it was a surprise to see that even Google has not fixed this issue yet! Again, no charge so fix it already!&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</description><link>http://legeronline.blogspot.com/2008/11/catch-ssl-certificate-errors-from.html</link><author>noreply@blogger.com (John Leger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOiU383gt6VO4ErK809A-C4Cx3Gl06EIO3tpthKZd4cQosYotD_JzkY4WQy5jmu1mf7qUA8BuSm9ToJUrZGkvhd7oEKKyTV2-ilbv1jQl4_48qeG_g99fRZpf9yvG0kHaQfVQY-OfCt0U/s72-c/SSLCertError.gif" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1088841307441866733.post-4659749010678493396</guid><pubDate>Fri, 14 Nov 2008 15:02:00 +0000</pubDate><atom:updated>2009-03-15T12:14:07.182-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.Net</category><category domain="http://www.blogger.com/atom/ns#">Generics</category><category domain="http://www.blogger.com/atom/ns#">SQLConnection</category><title>Patterns for closing SQL Connections consumed by the SQL Data Reader.</title><description>&lt;p&gt;On a recent contract engagement with a large company whose name I will not disclose I was surprised to witness many bad practices and the needless overlooking of SQL connection disposal. Although the origin of the code base dates back to .Net 1.0, I have a hard time in letting stuff like this slip by. I discussed this internally with our lead who replied nonchalantly about it. They indicated that there should be no reason to close the connection as per the statement of Microsoft linked and summarized below.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa326246&quot;&gt;Microsoft states, that for version 1.1 &lt;/a&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;If the SqlDataReader is created with CommandBehavior set to CloseConnection, closing the SqlDataReader closes the connection automatically.&lt;/p&gt;    &lt;p&gt;Below is an example of the code of reference. Although the command behavior sets the connection to close during command instantiation, what if there is an exception? Simply put, there is no way that the the command object will close and hence neither will the database connection!  &lt;br /&gt;&lt;/p&gt;    &lt;p&gt;&lt;/p&gt;    &lt;pre&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;    &lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; GetListOfImageSizes _&lt;br /&gt;    (&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;ByVal&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; someID &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; IList&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; strSQL &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 255, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 128);&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ci &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; FileImageInfo&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; alAnArrayList &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ArrayList&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; cn &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; SqlConnection(Blah)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; cmd &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; SqlCommand(strSQL, cn)&lt;br /&gt;    cmd.Parameters.Add(Blah) = someID&lt;br /&gt;    cn.Open()&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; rs &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;While&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; result.Read()&lt;br /&gt;        ci = &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; FileImageInfo(rs(1), rs(2))&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;If&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; IsNothing(alAnArrayList) &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Then&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;                alAnArrayList = &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ArrayList&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;If&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;            alAnArrayList.Add(ci)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;While&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;        rs.Close()&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;CType&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(alAnArrayList, IList)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Function&lt;p&gt; &lt;/p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;I am very much all about using patterns. More important, patterns that are well documented to work and that following industry best practice. I believe in order to excel at what you do, there needs to exist a high degree of pride and passion. The great developers lead by example and foster good ethics and practices of their craft!&lt;br /&gt;&lt;p&gt;    So with some minor code re-factoring, the following solution was introduced and ran through the debugger flawlessly. I have not spent the time to implement this everywhere. I have however laid the groundwork for others to follow the pattern if they so choose. Perhaps over time it will be implemented as there are many points in this application where the pattern can replace poorly implemented practices!&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;div align=&quot;left&quot;&gt;&lt;pre&gt;    &lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; RevList(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;ByVal&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; someID &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; IList&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; strSQL &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; = (Blah)&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ci &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BusObject&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; list &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; GenList(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Of&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BusObject)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; cn &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; SqlConnection(blah)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Using&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; cn&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; cmd &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; SqlCommand(strSQL, cn)&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Using&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; cmd&lt;br /&gt;            cmd.Parameters.Add(blah) = someID&lt;br /&gt;            cn.Open()&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Dim&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; result &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;While&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; result.Read()&lt;br /&gt;                ci = &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; BusObject(rs(1), rs(2))&lt;br /&gt;                list.Add(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;DirectCast&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(ci, BusObject))&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;While&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;                result.Close()&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Using&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; list&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Using&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;Function&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;p&gt;Helper class for dealing with lists generically.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; GenList(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Of&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; T)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Inherits&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; CollectionBase&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; Add(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;ByVal&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; value &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; T) &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Integer&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; List.Add(value)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Function&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Sub&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; Remove(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;ByVal&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; value &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; T)&lt;br /&gt;    List.Remove(value)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Sub&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;ReadOnly&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Property&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; Item(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;ByVal&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; index &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; T&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Get&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;DirectCast&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;(List.Item(index), T)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Get&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Property&lt;br /&gt;End&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Class&lt;/span&gt;&lt;/pre&gt;&lt;/blockquote&gt;</description><link>http://legeronline.blogspot.com/2008/11/patterns-for-closing-sqlconnections.html</link><author>noreply@blogger.com (John Leger)</author><thr:total>0</thr:total></item></channel></rss>