<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.connicus.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Terry Thibodeau's Blog</title><link>http://www.connicus.com/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>How Did I Get Started In Software Development?</title><link>http://www.connicus.com/archive/2008/07/15/how-did-i-get-started-in-software-development.aspx</link><pubDate>Tue, 15 Jul 2008 14:22:00 GMT</pubDate><guid isPermaLink="false">676f6b53-914a-4440-92e2-68dcb69a897b:107</guid><dc:creator>Terry Thibodeau</dc:creator><slash:comments>0</slash:comments><comments>http://www.connicus.com/comments/107.aspx</comments><wfw:commentRss>http://www.connicus.com/commentrss.aspx?PostID=107</wfw:commentRss><description>Called out by Sean Feldman . Here we go: How old were you when you first started in programming? Not counting Turtle, I think the first actual program I wrote was a MadLibs story generator in grade 7. I would have been 12 or 13. It's no Pong , but there...(&lt;a href="http://www.connicus.com/archive/2008/07/15/how-did-i-get-started-in-software-development.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.connicus.com/aggbug.aspx?PostID=107" width="1" height="1"&gt;</description><category domain="http://www.connicus.com/archive/tags/Personal/default.aspx">Personal</category></item><item><title>ALT.NET Canada Conference - time's running out</title><link>http://www.connicus.com/archive/2008/07/02/alt-net-canada-conference-time-s-running-out.aspx</link><pubDate>Wed, 02 Jul 2008 20:45:00 GMT</pubDate><guid isPermaLink="false">676f6b53-914a-4440-92e2-68dcb69a897b:105</guid><dc:creator>Terry Thibodeau</dc:creator><slash:comments>0</slash:comments><comments>http://www.connicus.com/comments/105.aspx</comments><wfw:commentRss>http://www.connicus.com/commentrss.aspx?PostID=105</wfw:commentRss><description>As one of the organizers of the ALT.NET Canada conference, I thought I should probably do the obligatory "Come on out" post.:) So, if you haven't heard already, we are holding the first ever ALT.NET Canada Conference in Calgary, Alberta from August 15-17,...(&lt;a href="http://www.connicus.com/archive/2008/07/02/alt-net-canada-conference-time-s-running-out.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.connicus.com/aggbug.aspx?PostID=105" width="1" height="1"&gt;</description><category domain="http://www.connicus.com/archive/tags/conferences/default.aspx">conferences</category></item><item><title>Consolidating and Version-controlling Development Settings</title><link>http://www.connicus.com/archive/2008/05/06/Consolidating-and-Version_2D00_controlling-Development-Settings.aspx</link><pubDate>Tue, 06 May 2008 18:45:00 GMT</pubDate><guid isPermaLink="false">676f6b53-914a-4440-92e2-68dcb69a897b:71</guid><dc:creator>Terry Thibodeau</dc:creator><slash:comments>2</slash:comments><comments>http://www.connicus.com/comments/71.aspx</comments><wfw:commentRss>http://www.connicus.com/commentrss.aspx?PostID=71</wfw:commentRss><description>Those who know me know that I hate repetition. Reducing duplication and improving productivity is usually the driving force behind much that I do with computers (other than my day job of software development). After installing Visual Studio 2008 and new...(&lt;a href="http://www.connicus.com/archive/2008/05/06/Consolidating-and-Version_2D00_controlling-Development-Settings.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.connicus.com/aggbug.aspx?PostID=71" width="1" height="1"&gt;</description><category domain="http://www.connicus.com/archive/tags/Resharper/default.aspx">Resharper</category><category domain="http://www.connicus.com/archive/tags/tools/default.aspx">tools</category><category domain="http://www.connicus.com/archive/tags/productivity/default.aspx">productivity</category><category domain="http://www.connicus.com/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>The miracle hair!</title><link>http://www.connicus.com/archive/2008/05/05/the-miracle-hair.aspx</link><pubDate>Mon, 05 May 2008 19:04:00 GMT</pubDate><guid isPermaLink="false">676f6b53-914a-4440-92e2-68dcb69a897b:97</guid><dc:creator>Terry Thibodeau</dc:creator><slash:comments>0</slash:comments><comments>http://www.connicus.com/comments/97.aspx</comments><wfw:commentRss>http://www.connicus.com/commentrss.aspx?PostID=97</wfw:commentRss><description>Since Justice appreciates my hair so much (see the last interview question), I thought I'd give the rest of the public a taste as well. Enjoy ;)...(&lt;a href="http://www.connicus.com/archive/2008/05/05/the-miracle-hair.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.connicus.com/aggbug.aspx?PostID=97" width="1" height="1"&gt;</description><category domain="http://www.connicus.com/archive/tags/About+Me/default.aspx">About Me</category></item><item><title>Testing NHibernate object mappings in isolation (Part 2 - dependencies)</title><link>http://www.connicus.com/archive/2008/02/25/testing-nhibernate-object-mappings-in-isolation-part-2-dependencies.aspx</link><pubDate>Mon, 25 Feb 2008 19:58:00 GMT</pubDate><guid isPermaLink="false">676f6b53-914a-4440-92e2-68dcb69a897b:93</guid><dc:creator>Terry Thibodeau</dc:creator><slash:comments>0</slash:comments><comments>http://www.connicus.com/comments/93.aspx</comments><wfw:commentRss>http://www.connicus.com/commentrss.aspx?PostID=93</wfw:commentRss><description>&lt;P&gt;I thought I should post an update to "&lt;A class="" title="Testing NHibernate object mappings in isolation" href="http://www.connicus.com/archive/2008/02/21/testing-nhibernate-object-mappings-in-isolation.aspx" target=_blank&gt;Testing NHibernate object mappings in isolation&lt;/A&gt;" as that post didn't address dependent objects in your mapping files. For a simple mapping to a class with only fields or component object references*, the previous method works fine. &lt;/P&gt;
&lt;P&gt;When you start adding references to other entities in your mapping files, you must also add those mapping file references to the Configuration object. I've refactored the code&amp;nbsp;from the previous post to load the mapping file resource based on the class type. Notice the test, "Should_map_Conference_class", adds its dependencies to the configuration.&lt;/P&gt;
&lt;DIV class=Code&gt;
&lt;P style="MARGIN:0px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;const&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;string&lt;/SPAN&gt; mappingFileAssemblyName = &lt;SPAN style="COLOR:#a31515;"&gt;"Namespace.NHibernateMappings"&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;string&lt;/SPAN&gt; customConfigPath = &lt;SPAN style="COLOR:#2b91af;"&gt;Path&lt;/SPAN&gt;.Combine(&lt;SPAN style="COLOR:#2b91af;"&gt;Directory&lt;/SPAN&gt;.GetCurrentDirectory(), &lt;SPAN style="COLOR:#a31515;"&gt;@"localNHibernate.cfg.xml"&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;Configuration&lt;/SPAN&gt; configuration;&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;[&lt;SPAN style="COLOR:#2b91af;"&gt;SetUp&lt;/SPAN&gt;]&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; TestInitialize()&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;{&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; configuration = &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;Configuration&lt;/SPAN&gt;()&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .Configure(customConfigPath);&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;}&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;[&lt;SPAN style="COLOR:#2b91af;"&gt;TearDown&lt;/SPAN&gt;]&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; TearDown()&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;{&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; &lt;SPAN style="COLOR:blue;"&gt;this&lt;/SPAN&gt;.configuration.BuildSessionFactory().Close();&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;}&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;[&lt;SPAN style="COLOR:#2b91af;"&gt;Test&lt;/SPAN&gt;]&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; Should_map_Conference_class()&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;{&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; AddSingleClass(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt; (&lt;SPAN style="COLOR:#2b91af;"&gt;Address&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; AddSingleClass(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt; (&lt;SPAN style="COLOR:#2b91af;"&gt;Category&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; AddSingleClass(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR:#2b91af;"&gt;Conference&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;}&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;Configuration&lt;/SPAN&gt; AddSingleClass(&lt;SPAN style="COLOR:#2b91af;"&gt;Type&lt;/SPAN&gt; persistentClassType)&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;{&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; &lt;SPAN style="COLOR:#2b91af;"&gt;Assembly&lt;/SPAN&gt; assembly = &lt;SPAN style="COLOR:#2b91af;"&gt;Assembly&lt;/SPAN&gt;.Load(mappingFileAssemblyName);&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; &lt;SPAN style="COLOR:blue;"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;this&lt;/SPAN&gt;.configuration.AddResource(mappingFileAssemblyName + &lt;SPAN style="COLOR:#a31515;"&gt;"."&lt;/SPAN&gt; + persistentClassType.Name + &lt;SPAN style="COLOR:#a31515;"&gt;".hbm.xml"&lt;/SPAN&gt;, assembly);&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;}&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;If I were using C# 3.0 on this project, I could create an extension method for the NHibernate Configuration class to allow me to do something like:&lt;/P&gt;
&lt;DIV class=Code&gt;
&lt;P style="MARGIN:0px;"&gt;configuration.AddSingleClass(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt; (&lt;SPAN style="COLOR:#2b91af;"&gt;Address&lt;/SPAN&gt;), assembly)&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .AddSingleClass(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR:#2b91af;"&gt;Category&lt;/SPAN&gt;), assembly)&lt;/P&gt;
&lt;P style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .AddSingleClass(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR:#2b91af;"&gt;Conference&lt;/SPAN&gt;), assembly);&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=footnote&gt;* - A component is a contained object that is persisted as a value type, not an entity. See &lt;EM&gt;Component Mapping&lt;/EM&gt; in the NHibernate documentation.&lt;/P&gt;&lt;img src="http://www.connicus.com/aggbug.aspx?PostID=93" width="1" height="1"&gt;</description><category domain="http://www.connicus.com/archive/tags/TDD/default.aspx">TDD</category><category domain="http://www.connicus.com/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.connicus.com/archive/tags/NHibernate/default.aspx">NHibernate</category></item></channel></rss>