<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://nhforge.org/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Your first NHibernate based application</title><link>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx</link><description>Quick starts, tutorials, code snippets, custom user types, application blocks and more...</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Your first NHibernate based application</title><link>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx</link><pubDate>Mon, 21 Dec 2009 22:30:32 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:30</guid><dc:creator>Joe Doyle</dc:creator><comments>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/comments.aspx</comments><description>Current revision posted to How to by Joe Doyle on 21/12/2009 07:30:32 p.m.&lt;br /&gt;
&lt;h2&gt;Your first NHibernate based application&lt;/h2&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="color:#ff8000;"&gt;&lt;span style="background: SpringGreen;"&gt;Wiki&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;extracted&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;from&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;original&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;blog&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;post&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;a href="/members/gabriel.schenker/default.aspx"&gt;&lt;span style="background: SpringGreen;"&gt;Gabriel&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Schenker&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;span style="background: SpringGreen;"&gt;Welcome&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;If&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;re&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;reading&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;assume&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ve&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;just&lt;/span&gt; &lt;a href="/media/p/4.aspx"&gt;&lt;span style="background: SpringGreen;"&gt;downloaded&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;/a&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;started&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tutorial&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;talk&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;through&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="background: SpringGreen;"&gt;Installing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: SpringGreen;"&gt;Defining&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;simple&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;business&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: SpringGreen;"&gt;Create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;load&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;save&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;business&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: SpringGreen;"&gt;Configure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;talk&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;local&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: SpringGreen;"&gt;Automatically&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;generate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: SpringGreen;"&gt;Writing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;simple&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;CRUD&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;pattern&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background: SpringGreen;"&gt;Using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Unit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Tests&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;make&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;working&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;correctly&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;what&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;re&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;aiming&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;But&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;things&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:)]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Lets&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;actually&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;doing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;something&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ZIP&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;just&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;downloaded&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Installing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;If&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ve&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;downloaded&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;binaries&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;zip&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;all&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;do&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;extract&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;somewhere&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sensible&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;usually&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;called&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SharedLibs&lt;/span&gt;&amp;nbsp; &lt;code&gt;&lt;span style="background: SpringGreen;"&gt;c:\Code\SharedLibs\NHibernate&lt;/span&gt;&lt;/code&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;extract&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;zip&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;there&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;But&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;whatever&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;re&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;comfortable&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SharedLib&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;from&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;references&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NUnit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;dlls&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;references&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;both&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;demo&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;unit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;That&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;!&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;installed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;easy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;huh)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;talk&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;through&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Visual&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Studio&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;moment&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;First&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;look&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;at&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;how&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;go&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;about&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;creating&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Note&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;dependent&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;on&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Visual&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Studio&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;2008&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Net&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Framework&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;3.5&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Project&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Before&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;building&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;application&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;business&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;objects&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;blank&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;put&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;them&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Fire&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;up&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Visual&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Studio&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Library&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;look&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;at&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;something&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;interesting&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;creating&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;business&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Defining&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Business&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Objects&lt;/span&gt;&lt;br /&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Lets&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defining&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;very&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;simple&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;For&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;moment&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;consists&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;one&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;has&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;3&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;properties&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Discontinued&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:210px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ProductDef.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;solution&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Product.cs&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;very&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;simple&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;uses&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;automatic&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;properties&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;feature&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;C&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;#&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;3.0&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;compiler&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;br /&gt;&lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Discontinued&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;able&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;persist&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;instances&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;relational)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;chosen&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;task&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;An&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;instance&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;corresponds&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;row&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;So&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;between&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;corresponding&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;done&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;either&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defining&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml-document&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;or&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;decorating&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;attributes&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Mapping&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Mappings&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml-document&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;call&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;b&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;hbm.xml&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Please&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;note&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;hbm&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;part&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;convention&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;used&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;automatically&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;recognize&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;Embedded&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Resource&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Build&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Action&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Windows&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Explorer&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;locate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;nhibernate-mapping.xsd&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;src&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;copy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SharedLibs&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;definition&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;when&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defining&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;VS&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;then&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;provide&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;intellisense&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;validation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;when&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;editing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;document&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Back&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;VS&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product.hbm.xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/properties.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Each&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;has&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;root&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;node&lt;/span&gt;&lt;/p&gt;
&lt;div id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:73647d35-a397-46d8-ad1c-a9edf8bbe509" class="wlWriterSmartContent"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;?&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;encoding&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;?&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;xmlns&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;assembly&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;FirstSolution&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;  &lt;span style="color:#008000;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;!--&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;more&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;info&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;here&lt;/span&gt; -&lt;span style="text-decoration: line-through; color: red;"&gt;Removed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;spammer&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;links&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;-&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;when&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;referencing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;always&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;provide&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fully&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;qualified&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;e.g.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSample.Domain.Product&lt;/span&gt;, &lt;span style="background: SpringGreen;"&gt;FirstSample)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;To&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;make&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;less&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;verbose&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;assembly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;classes&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;are&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implemented&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;classes&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;two&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;attributes&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;assembly&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;root&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;node&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;It&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;similar&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;statement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;C#&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;primary&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;key&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Technically&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;could&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;take&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;must&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defined&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;has&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;unique&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;But&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;common&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;surrogate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;key&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;instead&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;For&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;thus&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;call&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Id&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Guid&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;type&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Id&lt;/span&gt; but &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; can &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;well&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;int&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;or&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;long&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;System&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;br /&gt;&lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Guid&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Id&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Discontinued&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;complete&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;?&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;encoding&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;?&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;xmlns&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;assembly&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;FirstSolution&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;id&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Id&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;generator&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;guid&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;id&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Category&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Discontinued&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;doesn&lt;/span&gt;&amp;#39;t &lt;span style="text-decoration: line-through; color: red;"&gt;restore&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;way&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;such&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defines&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;many&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;reasonable&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defaults&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;So&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;if&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;don&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;t&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;provide&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;column&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;explicitly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt; the &lt;span style="text-decoration: line-through; color: red;"&gt;original&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;content&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;due&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;column&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;according&lt;/span&gt; to &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Or&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;automatically&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;infer&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;or&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;type&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;column&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;from&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;definition&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;As&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;consequence&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;my&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;cluttered&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;redundant&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;information&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Please&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;refer&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;online&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;documentation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;more&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;detailed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;explanation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;find&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html"&gt;&lt;span style="background: SpringGreen;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;solution&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;explorer&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;should&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;look&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;like&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Domain.cd&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;contains&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;diagram&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;simple&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;added&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;design&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;created&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;diagram&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;yourself&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;although&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;good&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;practice&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;required&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;purposes&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;excercise&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Configure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tell&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;provide&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;connection&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;details&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;form&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;connection&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;supports&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;many&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;many&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;products&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;call&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;hibernate.cfg.xml&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Set&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;its&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Copy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Output&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Copy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;always&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;are&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Server&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Compact&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Edition&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;enter&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;information&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;into&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;?&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;xml&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;encoding&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;?&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;hibernate-configuration&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;xmlns&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;urn:nhibernate-configuration-2.2&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;session-factory&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;connection.provider&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;dialect&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;NHibernate.Dialect.MsSqlCeDialect&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;connection.driver_class&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;NHibernate.Driver.SqlServerCeDriver&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;connection.connection_string&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Data&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Source=FirstSample.sdf&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;show_sql&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;true&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;session-factory&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="background: SpringGreen;"&gt;hibernate-configuration&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;With&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tell&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;MS&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Server&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Compact&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Edition&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;target&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;shall&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSample.sdf&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;=connection&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;string)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;also&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defined&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;see&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;SQL&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;generates&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sends&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;highly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;recommended&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;debugging&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;purposes&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;during&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;development)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Double&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;check&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;no&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;typos&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; an &lt;span style="text-decoration: line-through; color: red;"&gt;error&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;empty&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;FirstSample.sdf&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;choose&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Local&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Database&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;template&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AddNewItem.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Click&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ignore&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;DataSet&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;creation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;wizard&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;just&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;hit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Cancel)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Setup&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;It&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;time&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;setup&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;First&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;verify&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SharedLibs&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:180px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/SharedLibs.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;last&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;8&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;find&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Microsoft&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Server&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Compact&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Edition&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;directory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Programs&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/sqlce.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Note&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;System.Data.SqlServerCe.dll&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;located&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sub-folder&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Desktop&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;All&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;other&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;found&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;reference&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Additionally&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;references&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate.dll&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;nunit.framework.dll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Systm.Data.SqlServerCe.dll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;remember&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;reference&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;located&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SharedLibs&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder!)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Pay&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;attention&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;property&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Copy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Local&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;true&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;assembly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;System.Data.SqlServerCe.dll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;default&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;!&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;copy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;hibernate.cfg.xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;root&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;unit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Direct&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;action&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NUnit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;needs&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;access&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;GenerateSchema_Fixture&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;should&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;look&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;like&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex1.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;further&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;7&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sqce*.dll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;output&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;directory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;do&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;post-build&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;event&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;VS&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Enter&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;command&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;Post-build&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;event&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;command&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;line&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;copy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;$&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(ProjectDir)..\..\SharedLibs\sqlce*.dll&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;$&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(ProjectDir)$(OutDir)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AppProperties.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GenerateSchema_Fixture&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:370px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate.Cfg&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate.Tool.hbm2ddl&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NUnit.Framework&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Tests&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;TestFixture]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GenerateSchema_Fixture&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_generate_schema(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;cfg&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Configuration()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;cfg.Configure()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;cfg.AddAssembly&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;typeof&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product).Assembly);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SchemaExport(cfg).Execute&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;line&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;creates&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;instance&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;used&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;second&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;line&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tell&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;itself&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;look&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;out&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;information&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;do&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;provide&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;any&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;information&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;here&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;So&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;search&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;hibernate.cfg.xml&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;output&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;directory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;That&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;exactly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;what&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defined&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;settings&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;third&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;line&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tell&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;find&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;information&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;assembly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;contains&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;also&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;At&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;time&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;being&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;find&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;one&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;such&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product.hbm.xml)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;embedded&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;resource&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fourth&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;line&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;uses&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SchemaExport&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;helper&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;auto&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;-&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;magically&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;generate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;us&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SchemaExport&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;each&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;time&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;call&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;delete&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;data&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;recreate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Note&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;do&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;NOT&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;find&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;out&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;whether&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;does&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;its&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;job&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;correctly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;does&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;but&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;rater&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;whether&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;setup&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;system&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;correctly&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;However&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;check&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;see&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;newly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;created&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;If&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;a href="http://www.testdriven.net/"&gt;&lt;span style="background: SpringGreen;"&gt;TestDriven.Net&lt;/span&gt;&lt;/a&gt; &lt;span style="background: SpringGreen;"&gt;installed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;just&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;right&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;click&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;inside&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;choose&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Run&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Test(s&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;execute&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RunTest.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;If&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;every&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;thing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ok&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;should&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;see&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;result&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;output&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;window&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestResult.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;If&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;a href="http://www.jetbrains.com/resharper/"&gt;&lt;span style="background: SpringGreen;"&gt;ReSharper&lt;/span&gt;&lt;/a&gt; &lt;span style="background: SpringGreen;"&gt;installed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;just&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;clicking&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;yellow-green&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;circle&lt;/span&gt; on the &lt;span style="text-decoration: line-through; color: red;"&gt;site&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;left&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;border&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;choose&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Run&lt;/span&gt;&lt;/b&gt;.&amp;nbsp; &lt;span style="text-decoration: line-through; color: red;"&gt;Use&lt;/span&gt; &lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSTestinfo.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;result&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:90px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSRunTest.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;case&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Problems&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;If&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fails&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;double&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;check&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;find&lt;/span&gt; the &lt;span style="text-decoration: line-through; color: red;"&gt;History&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tab&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;target&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;directory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;m:dev\projects\FirstSolution\src\FirstSolution.Tests\bin\debug&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/InCaseOfPb.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Double&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;check&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;also&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;if&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;no&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;typos&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;hibernate.cfg.xml)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;or&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product.hbm.xml).&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Finally&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;check&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;whether&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Build&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Action&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product.hbm.xml)&lt;/span&gt; to &lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Embedded&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Resource&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;continue&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;if&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;succeeds&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;CRUD&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;operations&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;obviously&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;system&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ready&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;successfully&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implemented&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Domain&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defined&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configured&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Finally&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;used&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;automatically&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;generate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;from&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;files)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;spirit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;DDD&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;see&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;e.g&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;a href="http://domaindrivendesign.org/books/"&gt;&lt;span style="background: SpringGreen;"&gt;Domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Driven&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Design&lt;/span&gt;&lt;/a&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Eric&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Evans&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;all&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;crud&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;operations&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;create,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;read&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;update&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;delete)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;interface&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;part&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;where&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implementation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;!&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implementation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;infrastructure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;specific&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;want&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;keep&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;persistence&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ignorant&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;PI).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;interface&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Call&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;interface&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;System&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;System.Collections.Generic&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;interface&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Update(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Remove(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetById(Guid&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;productId)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByName&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;ICollection&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByCategory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;category)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository_Fixture&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;solution&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:270px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;TestFixture]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository_Fixture&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ISessionFactory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;configuration;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;TestFixtureSetUp]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;TestFixtureSetUp(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Configuration()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;configuration.Configure();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;configuration.AddAssembly(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;typeof&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product).Assembly);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;configuration.BuildSessionFactory();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fourth&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;line&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;TestFixtureSetUp&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;factory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;expensive&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;process&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;should&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;thus&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;executed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;once&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;That&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;reason&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;why&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;put&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;into&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;executed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;once&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;during&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;cycle&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;To&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;keep&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;methods&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;side&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;effect&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;free&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;re-create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;before&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;execution&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;each&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Thus&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;SetUp]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SetupContext(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SchemaExport(_configuration).Execute&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;And&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;instance&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;adding&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;called&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Repositories&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;FirstSolution&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;ProductRepository&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Make&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;ProductRepository&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;inherit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;from&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;interface&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:652px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;System&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;System.Collections.Generic&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Repositories&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Update(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Remove(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetById(Guid&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;productId&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByName&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ICollection&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByCategory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;category&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Manipulating&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Data&lt;/span&gt;&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;go&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;back&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository_Fixture&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;      &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_add_new_product(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;repository.Add(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;run&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fail&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;yet&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implemented&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;do&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;But&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;wait&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;little&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;helper&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;provides&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;us&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;objects&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;on&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;demand&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:523px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate.Cfg&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;FirstSolution.Repositories&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernateHelper&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;static&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ISessionFactory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;static&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ISessionFactory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SessionFactory&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;_sessionFactory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Configuration()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="background: SpringGreen;"&gt;configuration.Configure()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    &lt;span style="background: SpringGreen;"&gt;configuration.AddAssembly&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product).Assembly);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configuration.BuildSessionFactory()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;static&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;OpenSession(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SessionFactory.OpenSession()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;creates&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;factory&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;time&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;client&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;needs&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ITransaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;transaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;session.Save(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;second&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;run&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;again&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fail&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;message&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ShouldBeVirtual.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;That&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;because&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;default&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configured&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt;&lt;b&gt;&amp;nbsp;&lt;a href="http://martinfowler.com/eaaCatalog/lazyLoad.html"&gt;&lt;span style="background: SpringGreen;"&gt;lazy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;load&lt;/span&gt;&lt;/a&gt;&lt;/b&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;all&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entities&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;That&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;recommended&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;approach&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;warmly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;recommend&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;change&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;maximum&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;flexibility&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;How&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;solve&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;issue&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;?&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;It&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;easy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;just&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;make&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;all&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;properties&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;methods&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object(s&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;virtual&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;do&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Guid&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Id&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Discontinued&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;set&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;run&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;again&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;It&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;should&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;succeed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;output&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestOutput.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Note&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sql&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;spit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;out&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;think&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;successfully&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;inserted&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;into&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;But&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;whether&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;really&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;so&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;extend&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;our&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:313px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_add_new_product(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;repository.Add(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#008000;"&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;try&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;load&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.Get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;(product.Id);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#008000;"&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;was&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;successfully&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;inserted&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="background: SpringGreen;"&gt;Assert.IsNotNull(fromDb)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="background: SpringGreen;"&gt;Assert.AreNotSame(product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="background: SpringGreen;"&gt;Assert.AreEqual(product.Name&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb.Name)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="background: SpringGreen;"&gt;Assert.AreEqual(product.Category&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb.Category)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Run&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;again&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Hopefully&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;succeed..&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;are&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ready&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;also&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;other&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;methods&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;For&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;testing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;would&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;rather&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;table&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;already&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;containing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;some&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;products&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Nothing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;easier&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;than&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Just&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;CreateInitialData&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:355px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;readonly&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;]&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;products&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Melon&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Pear&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Milk&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Coca&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Cola&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Pepsi&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Cola&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Category&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;CreateInitialData(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ITransaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;transaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;foreach&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;products)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                        &lt;span style="background: SpringGreen;"&gt;session.Save(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="background: SpringGreen;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Call&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;from&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SetupContext&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;after&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;create&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;call&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;are&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;done&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;each&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;time&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;after&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;created&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;populated&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;some&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;products&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Update&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_update_existing_product(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;products[0];&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;product.Name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Yellow&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Pear&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;repository.Update(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#008000;"&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;/&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;try&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;load&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.Get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;(product.Id);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="background: SpringGreen;"&gt;Assert.AreEqual(product.Name&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb.Name)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;When&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;running&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;time&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fail&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Update&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;has&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;yet&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;been&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implemented&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;expected&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;behavior&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;since&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;TDD&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;time&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;run&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;should&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;always&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fail&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Analogous&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Update&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;difference&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;call&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;update&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;instead&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;save&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Update(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ITransaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;transaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;session.Update(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Run&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;again&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;watch&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;succeed&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestSucceed.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;delete&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;straight&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;forward&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;When&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;testing&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;whether&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;record&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;has&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;really&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;been&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;deleted&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;just&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;assert&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;value&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;returned&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;equal&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;null&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Here&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:227px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_remove_existing_product(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;products[0];&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;repository.Remove(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;_&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.Get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;(product.Id);&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;Assert.IsNull(fromDb)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;here&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implementation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Remove&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Remove(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ITransaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;transaction&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;session.Delete(product)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Querying&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Database&lt;/span&gt;&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;We&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;still&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;three&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;methods&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;query&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;objects&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;most&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;easy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;one&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetById&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;First&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;write&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_get_existing_product_by_id(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository.GetById(_products[1].Id)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.IsNotNull(fromDb)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.AreNotSame(_products[1]&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.AreEqual(_products[1].Name&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb.Name)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;then&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fulfill&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetById(Guid&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;productId&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session.Get&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;(productId);&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Now&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;was&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;easy&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;For&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;two&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;methods&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByName&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;As&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;usual&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;we&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;write&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_get_existing_product_by_name(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository.GetByName(_products[1].Name)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.IsNotNull(fromDb)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.AreNotSame(_products[1]&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.AreEqual(_products[1].Id&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb.Id)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implementation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByName&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;done&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;two&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;different&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;approaches&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;first&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Hibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Query&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Language&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;second&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;one&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HCQ&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Hibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Criteria&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Query)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Let&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;start&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;oriented&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;query&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;language&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;similar&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;but&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;equal&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SQL&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;To&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;added&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implemetation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByName&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HCQ&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;below&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;works&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;expected&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;returns&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;above&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;introduced&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;commonly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;used&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;technique&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;when&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;It&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;s&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;called&lt;/span&gt; &lt;a href="http://en.wikipedia.org/wiki/Fluent_interface"&gt;&lt;span style="background: SpringGreen;"&gt;fluent&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;interfaces&lt;/span&gt;&lt;/a&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;As&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;result&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;less&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;verbose&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;easier&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;understand&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;see&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;query&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;embedded&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;named)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;parameters&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Parameters&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;are&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;prefixed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;defines&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;many&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;helper&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;methods&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;like&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SetString&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;used&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;example&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;assign&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;values&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;various&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;types&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;those&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;parameters&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Finally&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;UniqueResult&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tell&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;expect&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;one&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;record&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;If&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;more&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;than&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;one&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;record&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;returned&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;query&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;then&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;exception&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;raised&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;To&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;get&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;more&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;information&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;about&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;please&lt;/span&gt; read &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/queryhql.html"&gt;&lt;span style="background: SpringGreen;"&gt;online&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;documentation&lt;/span&gt;&lt;/a&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;second&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;version&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;uses&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;criteria&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;query&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;search&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;requested&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;reference&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt;&amp;nbsp; &lt;span style="background: SpringGreen;"&gt;NHibernate.Criterion&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;on&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;page&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByName&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;CreateCriteria(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product))&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Add(Restrictions.Eq(&lt;/span&gt;&lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;UniqueResult&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;();&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Many&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;users&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;think&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;that&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;approach&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;more&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;object&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;oriented&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;On&lt;/span&gt; the &lt;span style="background: SpringGreen;"&gt;other&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;hand&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;complex&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;query&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;written&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;criteria&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;syntax&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;quickly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;become&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;difficult&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;understand&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;last&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByCategory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;returns&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;list&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;products&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;The&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implemented&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:314px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="background: SpringGreen;"&gt;[&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Can_get_existing_products_by_category(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;IProductRepository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository.GetByCategory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.AreEqual(2&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb.Count)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.IsTrue(IsInCollection(_products[0]&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb))&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;Assert.IsTrue(IsInCollection(_products[1]&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb))&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;IsInCollection(Product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ICollection&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;foreach&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;item&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;fromDb&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;if&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;product.Id&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;item.Id&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;method&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;itself&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;might&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;contain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;following&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt;&lt;/p&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ICollection&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByCategory&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;category&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;ISession&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="background: SpringGreen;"&gt;var&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;products&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;=&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;session&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;CreateCriteria(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Product))&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Add(Restrictions.Eq(&lt;/span&gt;&lt;span style="color:#006080;"&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;Category&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;category)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;                    &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;List&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;lt;Product&amp;gt;();&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="background: SpringGreen;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;products&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;Summary&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;In&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; article &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;shown&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;how&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;basic&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;define&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;mapping&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;how&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;configure&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;able&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;persist&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;objects&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;shown&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;how&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;typically&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;write&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;CRUD&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;methods&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;domain&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;objects&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;I&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;taken&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;MS&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SQL&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Compact&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Edition&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;sample&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;but&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;any&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;other&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;supported&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;used&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;only&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;change&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;hibernate.cfg.xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;accordingly)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Ee&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;no&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;dependencies&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;on&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;external&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;frameworks&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;or&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tools&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;other&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;than&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;itself&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.NET&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;course&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;never&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;counts&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;here)&lt;/span&gt;.&lt;/p&gt;</description></item><item><title>Your first NHibernate based application</title><link>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/revision/12.aspx</link><pubDate>Mon, 21 Dec 2009 22:30:17 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:301</guid><dc:creator>Joe Doyle</dc:creator><comments>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/comments.aspx</comments><description>Revision 12 posted to How to by Joe Doyle on 21/12/2009 07:30:17 p.m.&lt;br /&gt;
&lt;h2&gt;Your first NHibernate based application&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://www.dicapriophotography.com"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;san&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;diego&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;wedding&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;photographer&lt;/span&gt;&lt;/a&gt;
&lt;a href="http://www.dicapriophotography.com"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;san&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;diego&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;wedding&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;photographers&lt;/span&gt;&lt;p&gt;&lt;a href="http://www.dicapriophotography.com"&gt;&lt;span style="background: SpringGreen;"&gt;-&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Removed&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;spammer&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;links&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;but&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;t&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;restore&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;original&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;content&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;due&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;an&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;error&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;on&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;site&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&amp;nbsp; &lt;span style="background: SpringGreen;"&gt;Use&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;History&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;tab&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;read&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;article&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;/a&gt;&lt;a href="http://www.dicapriophotography.com"&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Your first NHibernate based application</title><link>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/revision/11.aspx</link><pubDate>Mon, 21 Dec 2009 07:32:56 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:300</guid><dc:creator>raymond456</dc:creator><comments>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/comments.aspx</comments><description>Revision 11 posted to How to by raymond456 on 21/12/2009 04:32:56 a.m.&lt;br /&gt;
&lt;h2&gt;Your first NHibernate based application&lt;/h2&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="color:#ff8000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Wiki&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;extracted&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;from&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;original&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;blog&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;post&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;a href="/members/gabriel.schenker/default.aspx"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Gabriel&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Schenker&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Welcome&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;If&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;re&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;reading&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;assume&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ve&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;just&lt;/span&gt; &lt;a href="/media/p/4.aspx"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;downloaded&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;/a&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;started&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tutorial&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;talk&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;through&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Installing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Defining&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;simple&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;business&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;load&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;save&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;business&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Configure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;talk&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;local&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Automatically&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;generate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Writing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;simple&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;CRUD&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;pattern&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Unit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Tests&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;make&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;working&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;correctly&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;what&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;re&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;aiming&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;But&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;things&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:)]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Lets&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;actually&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;doing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;something&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ZIP&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;just&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;downloaded&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Installing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;If&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ve&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;downloaded&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;binaries&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;zip&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;all&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;need&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;do&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;extract&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;somewhere&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sensible&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;usually&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;called&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SharedLibs&lt;/span&gt;&amp;nbsp; &lt;code&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;c:\Code\SharedLibs\NHibernate&lt;/span&gt;&lt;/code&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;extract&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;zip&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;there&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;But&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;whatever&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;re&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;comfortable&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SharedLib&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;from&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;need&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;references&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NUnit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;dlls&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;references&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;both&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;demo&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;unit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;That&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;!&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;installed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;easy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;huh)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;talk&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;through&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Visual&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Studio&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;moment&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;First&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;look&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;at&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;how&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;go&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;about&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;creating&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Note&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;dependent&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;on&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Visual&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Studio&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;2008&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Net&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Framework&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;3.5&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Project&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Before&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;building&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;application&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;business&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;objects&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;need&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;blank&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;put&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;them&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Fire&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;up&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Visual&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Studio&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Library&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;look&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;at&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;something&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;interesting&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;creating&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;business&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Defining&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Business&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Objects&lt;/span&gt;&lt;br /&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Lets&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defining&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;very&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;simple&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;For&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;moment&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;consists&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;one&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;has&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;3&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;properties&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Discontinued&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:210px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ProductDef.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;solution&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product.cs&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;very&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;simple&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;uses&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;automatic&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;properties&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;feature&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;C&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;#&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;3.0&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;compiler&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;br /&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt;&lt;br /&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Discontinued&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;able&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;persist&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;instances&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;relational)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;chosen&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;task&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;An&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;instance&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;corresponds&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;row&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;So&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;between&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;corresponding&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;done&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;either&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defining&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml-document&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;or&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;decorating&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;attributes&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Mapping&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Mappings&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml-document&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;call&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;b&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hbm.xml&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Please&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;note&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;hbm&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;part&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;convention&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;used&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;automatically&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;recognize&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Embedded&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Resource&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Build&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Action&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Windows&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Explorer&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;locate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;nhibernate-mapping.xsd&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;src&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;copy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SharedLibs&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;schema&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;definition&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;when&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defining&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;VS&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;then&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;provide&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;intellisense&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;validation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;when&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;editing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;document&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Back&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;VS&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;schema&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product.hbm.xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/properties.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Each&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;has&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;hibernate-mapping&amp;gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;root&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;node&lt;/span&gt;&lt;/p&gt;
&lt;div id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:73647d35-a397-46d8-ad1c-a9edf8bbe509" class="wlWriterSmartContent"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;?&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;encoding&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;?&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;xmlns&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;assembly&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;FirstSolution&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;  &lt;span style="color:#008000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;!--&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;more&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;info&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;here&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;-&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;-&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;when&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;referencing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;always&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;provide&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fully&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;qualified&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;e.g.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample.Domain.Product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;To&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;make&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;less&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;verbose&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;assembly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;classes&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;are&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implemented&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;classes&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;two&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;attributes&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;assembly&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;root&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;node&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;It&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;similar&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;statement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;C#&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;primary&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;key&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Technically&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;could&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;take&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;must&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defined&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;has&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;unique&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;But&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;common&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;surrogate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;key&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;instead&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;For&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;thus&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;call&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Id&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Guid&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;type&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Id&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;but&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;well&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;int&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;or&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;long&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;System&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;br /&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt;&lt;br /&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Guid&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Id&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Discontinued&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;complete&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;?&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;encoding&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;?&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;xmlns&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;assembly&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;FirstSolution&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;id&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Id&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;generator&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;guid&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;id&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Category&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Discontinued&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate-mapping&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;doesn&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;t&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;way&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;such&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defines&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;many&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;reasonable&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defaults&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;So&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;if&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;don&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;t&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;provide&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;column&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;explicitly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;column&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;according&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Or&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;automatically&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;infer&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;or&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;type&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;column&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;from&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;definition&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;As&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;consequence&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;my&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;cluttered&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;redundant&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;information&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Please&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;refer&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;online&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;documentation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;more&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;detailed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;explanation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;You&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;find&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;solution&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;explorer&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;should&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;look&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;like&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Domain.cd&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;contains&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;diagram&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;simple&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;You&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;added&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;design&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;created&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;diagram&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;yourself&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;although&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;good&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;practice&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;required&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;purposes&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;excercise&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Configure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tell&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;provide&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;connection&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;details&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;form&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;connection&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;supports&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;many&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;many&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;products&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;call&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;hibernate.cfg.xml&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Set&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;its&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Copy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Output&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Copy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;always&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;are&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Server&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Compact&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Edition&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;enter&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;information&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;into&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;?&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;xml&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;version&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;encoding&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;?&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate-configuration&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;xmlns&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;urn:nhibernate-configuration-2.2&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;session-factory&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;connection.provider&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;dialect&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.Dialect.MsSqlCeDialect&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;connection.driver_class&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.Driver.SqlServerCeDriver&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;connection.connection_string&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Data&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Source=FirstSample.sdf&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;show_sql&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;true&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;session-factory&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate-configuration&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;With&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configuration&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tell&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;MS&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Server&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Compact&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Edition&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;target&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;shall&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample.sdf&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=connection&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;string)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;also&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defined&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;see&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;SQL&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;generates&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sends&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;highly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;recommended&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;debugging&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;purposes&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;during&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;development)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Double&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;check&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;no&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;typos&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;empty&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample.sdf&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;choose&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Local&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Database&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;template&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AddNewItem.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Click&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ignore&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;DataSet&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;creation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;wizard&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;just&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;hit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Cancel)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Setup&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;It&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;time&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;setup&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;First&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;verify&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SharedLibs&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:180px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/SharedLibs.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;last&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;8&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;find&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Microsoft&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Server&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Compact&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Edition&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;directory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Programs&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/sqlce.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Note&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;System.Data.SqlServerCe.dll&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;located&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sub-folder&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Desktop&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;All&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;other&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;found&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;reference&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Additionally&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;references&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.dll&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;nunit.framework.dll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Systm.Data.SqlServerCe.dll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;remember&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;reference&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;located&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SharedLibs&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder!)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Pay&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;attention&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;property&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Copy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Local&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;true&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;assembly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;System.Data.SqlServerCe.dll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;default&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;!&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;copy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;hibernate.cfg.xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;root&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;unit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Direct&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;action&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NUnit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;needs&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;access&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;GenerateSchema_Fixture&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;should&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;look&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;like&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex1.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;further&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;need&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;7&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sqce*.dll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;output&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;directory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;do&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;post-build&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;event&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;VS&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Enter&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;command&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Post-build&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;event&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;command&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;line&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;copy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;$&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(ProjectDir)..\..\SharedLibs\sqlce*.dll&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;$&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(ProjectDir)$(OutDir)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AppProperties.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GenerateSchema_Fixture&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:370px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.Cfg&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.Tool.hbm2ddl&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NUnit.Framework&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Tests&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;TestFixture]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GenerateSchema_Fixture&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_generate_schema(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;cfg&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Configuration()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;cfg.Configure()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;cfg.AddAssembly&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;typeof&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product).Assembly);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SchemaExport(cfg).Execute&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;line&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;creates&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;instance&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configuration&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;used&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;second&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;line&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tell&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;itself&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;look&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;out&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configuration&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;information&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;do&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;provide&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;any&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;information&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;here&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;So&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;search&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;called&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate.cfg.xml&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;output&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;directory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;That&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;exactly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;what&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defined&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;settings&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;third&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;line&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tell&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;find&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;information&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;assembly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;contains&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;also&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;At&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;time&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;being&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;find&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;one&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;such&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product.hbm.xml)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;embedded&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;resource&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fourth&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;line&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;uses&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SchemaExport&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;helper&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;auto&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;-&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;magically&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;generate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;schema&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;us&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SchemaExport&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;each&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;time&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;call&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;delete&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;data&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;recreate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Note&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;do&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;NOT&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;find&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;out&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;whether&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;does&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;its&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;job&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;correctly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;does&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;but&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;rater&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;whether&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;setup&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;system&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;correctly&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;However&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;check&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;see&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;newly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;created&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;If&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;a href="http://www.testdriven.net/"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;TestDriven.Net&lt;/span&gt;&lt;/a&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;installed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;just&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;right&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;click&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;inside&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;choose&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Run&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Test(s&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;execute&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RunTest.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;If&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;every&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;thing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ok&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;should&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;see&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;result&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;output&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;window&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestResult.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;If&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;a href="http://www.jetbrains.com/resharper/"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ReSharper&lt;/span&gt;&lt;/a&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;installed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;just&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;clicking&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;yellow-green&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;circle&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;on&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;left&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;border&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;choose&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Run&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSTestinfo.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;result&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:90px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSRunTest.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;case&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Problems&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;If&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fails&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;double&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;check&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;find&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;target&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;directory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;m:dev\projects\FirstSolution\src\FirstSolution.Tests\bin\debug&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/InCaseOfPb.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Double&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;check&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;also&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;if&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;no&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;typos&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configuration&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;hibernate.cfg.xml)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;or&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product.hbm.xml).&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Finally&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;check&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;whether&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Build&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Action&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product.hbm.xml)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Embedded&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Resource&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;continue&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;if&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;succeeds&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;CRUD&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;operations&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;obviously&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;system&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ready&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;successfully&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implemented&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Domain&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defined&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configured&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Finally&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;used&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;automatically&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;generate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;schema&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;from&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;files)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;spirit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;DDD&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;see&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;e.g&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;a href="http://domaindrivendesign.org/books/"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Driven&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Design&lt;/span&gt;&lt;/a&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Eric&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Evans&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;all&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;crud&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;operations&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;create,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;read&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;update&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;delete)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;interface&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;part&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;where&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implementation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;!&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implementation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;infrastructure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;specific&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;want&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;keep&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;persistence&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ignorant&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;PI).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;interface&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Call&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;interface&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;System&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;System.Collections.Generic&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;interface&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Update(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Remove(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetById(Guid&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;productId)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByName&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;ICollection&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByCategory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;category)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository_Fixture&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;solution&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:270px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;TestFixture]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository_Fixture&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ISessionFactory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Configuration&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;configuration;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;TestFixtureSetUp]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;TestFixtureSetUp(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;configuration&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Configuration()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;configuration.Configure();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;configuration.AddAssembly(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;typeof&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product).Assembly);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;configuration.BuildSessionFactory();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fourth&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;line&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;TestFixtureSetUp&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;factory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;expensive&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;process&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;should&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;thus&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;executed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;once&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;That&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;reason&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;why&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;put&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;into&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;executed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;once&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;during&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;cycle&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;To&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;keep&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;methods&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;side&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;effect&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;free&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;re-create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;schema&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;before&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;execution&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;each&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Thus&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;SetUp]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SetupContext(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SchemaExport(_configuration).Execute&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;And&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;instance&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;adding&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;called&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Repositories&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;project&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;folder&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Make&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;inherit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;from&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;interface&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:652px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;System&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;System.Collections.Generic&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Repositories&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Update(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Remove(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetById(Guid&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;productId&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByName&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ICollection&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByCategory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;category&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;throw&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NotImplementedException()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Manipulating&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Data&lt;/span&gt;&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;go&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;back&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository_Fixture&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;      &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_add_new_product(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;repository.Add(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;run&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fail&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;yet&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implemented&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;do&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;But&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;wait&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;little&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;helper&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;provides&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;us&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;objects&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;on&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;demand&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:523px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Domain&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.Cfg&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;namespace&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;FirstSolution.Repositories&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernateHelper&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;static&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ISessionFactory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;static&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ISessionFactory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SessionFactory&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;_sessionFactory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configuration&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Configuration()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;configuration.Configure()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;configuration.AddAssembly&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product).Assembly);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configuration.BuildSessionFactory()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;static&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;OpenSession(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SessionFactory.OpenSession()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;creates&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;factory&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;time&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;client&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;needs&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ITransaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;transaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;session.Save(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;second&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;run&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;again&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fail&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;message&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ShouldBeVirtual.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;That&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;because&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;default&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configured&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt;&lt;b&gt;&amp;nbsp;&lt;a href="http://martinfowler.com/eaaCatalog/lazyLoad.html"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;lazy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;load&lt;/span&gt;&lt;/a&gt;&lt;/b&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;all&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entities&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;That&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;recommended&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;approach&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;warmly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;recommend&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;change&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;maximum&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;flexibility&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;How&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;solve&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;issue&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;?&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;It&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;easy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;just&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;make&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;all&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;properties&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;methods&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object(s&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;virtual&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;do&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt;&lt;br /&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Guid&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Id&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;virtual&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Discontinued&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;set&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;run&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;again&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;It&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;should&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;succeed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;output&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestOutput.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Note&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sql&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;spit&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;out&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;think&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;successfully&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;inserted&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;into&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;But&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;whether&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;really&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;so&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;extend&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;our&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:313px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_add_new_product(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;repository.Add(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#008000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;try&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;load&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.Get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;(product.Id);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#008000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;was&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;successfully&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;inserted&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.IsNotNull(fromDb)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreNotSame(product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreEqual(product.Name&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb.Name)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreEqual(product.Category&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb.Category)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Run&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;again&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Hopefully&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;succeed..&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;are&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ready&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;also&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;other&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;methods&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;For&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;testing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;would&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;rather&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;table&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;already&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;containing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;some&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;products&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Nothing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;easier&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;than&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Just&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;CreateInitialData&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;class&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:355px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;readonly&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;]&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;products&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Melon&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Pear&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Milk&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Coca&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Cola&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Pepsi&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Cola&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Category&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;CreateInitialData(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ITransaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;transaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;foreach&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;products)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                        &lt;span style="text-decoration: line-through; color: red;"&gt;session.Save(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Call&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;from&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SetupContext&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;after&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;create&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;schema&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;call&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;are&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;done&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;each&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;time&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;after&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;schema&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;created&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;populated&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;some&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;products&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Update&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_update_existing_product(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;products[0];&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;product.Name&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Yellow&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Pear&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;repository.Update(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#008000;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;/&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;try&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;load&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.Get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;(product.Id);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreEqual(product.Name&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb.Name)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;When&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;running&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;time&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;will&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fail&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Update&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;has&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;yet&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;been&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implemented&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;expected&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;behavior&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;since&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;TDD&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;time&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;run&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;should&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;always&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fail&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Analogous&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Update&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;difference&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;call&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;update&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;instead&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;save&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Update(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ITransaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;transaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;session.Update(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Run&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;again&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;watch&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;it&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;succeed&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestSucceed.png" alt="" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;delete&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;straight&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;forward&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;When&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;testing&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;whether&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;record&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;has&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;really&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;been&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;deleted&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;just&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;assert&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;value&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;returned&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;equal&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;null&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Here&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:227px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_remove_existing_product(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;products[0];&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;repository.Remove(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;_&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;sessionFactory.OpenSession())&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.Get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;(product.Id);&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.IsNull(fromDb)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;here&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implementation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Remove&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Remove(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ITransaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;transaction&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.BeginTransaction()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;session.Delete(product)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;transaction.Commit()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Querying&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Database&lt;/span&gt;&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;We&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;still&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;three&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;methods&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;query&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;objects&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;most&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;easy&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;one&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetById&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;First&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;write&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_get_existing_product_by_id(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository.GetById(_products[1].Id)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.IsNotNull(fromDb)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreNotSame(_products[1]&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreEqual(_products[1].Name&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb.Name)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;then&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fulfill&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetById(Guid&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;productId&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session.Get&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;(productId);&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Now&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;was&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;easy&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;For&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;two&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;methods&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;use&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByName&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;As&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;usual&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;we&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;write&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_get_existing_product_by_name(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository.GetByName(_products[1].Name)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.IsNotNull(fromDb)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreNotSame(_products[1]&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreEqual(_products[1].Id&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb.Id)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implementation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByName&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;done&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;two&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;different&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;approaches&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;first&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Hibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Query&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Language&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;second&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;one&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HCQ&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Hibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Criteria&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Query)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Let&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;start&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HQL&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;oriented&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;query&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;language&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;similar&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;but&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;not&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;equal&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SQL&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;To&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;added&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implemetation&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByName&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HQL&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HCQ&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;below&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;works&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;expected&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;returns&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;entity&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;above&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;introduced&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;commonly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;used&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;technique&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;when&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;It&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;s&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;called&lt;/span&gt; &lt;a href="http://en.wikipedia.org/wiki/Fluent_interface"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;fluent&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;interfaces&lt;/span&gt;&lt;/a&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;As&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;result&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;less&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;verbose&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;easier&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;understand&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;You&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;see&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;query&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;which&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;embedded&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;named)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;parameters&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Parameters&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;are&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;prefixed&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;:&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;#39;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;defines&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;many&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;helper&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;methods&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;like&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SetString&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;used&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;example&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;assign&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;values&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;various&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;types&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;those&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;parameters&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Finally&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;UniqueResult&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tell&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;expect&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;one&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;record&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;If&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;more&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;than&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;one&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;record&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;returned&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;by&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;query&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;then&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;an&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;exception&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;raised&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;To&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;get&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;more&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;information&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;about&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;HQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;please&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;read&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/queryhql.html"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;online&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;documentation&lt;/span&gt;&lt;/a&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;second&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;version&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;uses&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;criteria&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;query&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;search&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;requested&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;You&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;need&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;add&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;reference&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt;&amp;nbsp; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate.Criterion&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;on&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;page&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByName&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;CreateCriteria(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product))&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add(Restrictions.Eq(&lt;/span&gt;&lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;name)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;UniqueResult&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;();&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Many&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;users&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;think&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;that&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;approach&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;more&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;object&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;oriented&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;On&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;other&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;hand&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;complex&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;query&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;written&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;with&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;criteria&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;syntax&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;quickly&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;become&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;difficult&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;understand&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;last&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;is&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByCategory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;This&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;returns&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;list&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;products&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;The&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implemented&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;follows&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:314px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;[&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Test]&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Can_get_existing_products_by_category(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;IProductRepository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;new&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ProductRepository()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;repository.GetByCategory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.AreEqual(2&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb.Count)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.IsTrue(IsInCollection(_products[0]&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb))&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;Assert.IsTrue(IsInCollection(_products[1]&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb))&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;private&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;bool&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;IsInCollection(Product&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;product&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ICollection&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;foreach&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;item&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;fromDb&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;if&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;product.Id&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;item.Id&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;method&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;itself&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;might&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;contain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;following&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;code&lt;/span&gt;&lt;/p&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;public&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;ICollection&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;GetByCategory&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;category&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;using&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;ISession&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernateHelper.OpenSession()&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="text-decoration: line-through; color: red;"&gt;var&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;products&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;=&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;session&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;CreateCriteria(&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Product))&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Add(Restrictions.Eq(&lt;/span&gt;&lt;span style="color:#006080;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;Category&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;category)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;br /&gt;                    &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;List&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;Product&amp;gt;();&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;return&lt;/span&gt;&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;products&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span style="text-decoration: line-through; color: red;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;Summary&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;In&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;this&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;article&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;shown&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;how&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;implement&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;basic&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;define&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;mapping&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;a&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;how&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;configure&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;able&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;persist&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;objects&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;in&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;shown&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;how&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;typically&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;write&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;test&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;CRUD&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;methods&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;for&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;your&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;objects&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;I&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;taken&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;MS&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;SQL&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Compact&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Edition&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;as&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;sample&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;but&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;any&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;other&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;supported&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;can&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;be&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;used&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;you&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;only&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;to&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;change&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;hibernate.cfg.xml&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;file&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;accordingly)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;Ee&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;have&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;no&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;dependencies&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;on&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;external&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;frameworks&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;or&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;tools&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;other&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;than&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;the&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;database&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;and&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;NHibernate&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;itself&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;(&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.NET&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;of&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;course&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;never&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;counts&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;here)&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt;&lt;p&gt;&lt;a href="http://www.dicapriophotography.com"&gt;&lt;span style="background: SpringGreen;"&gt;san&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;diego&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;wedding&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;photographer&lt;/span&gt;&lt;/a&gt;
&lt;a href="http://www.dicapriophotography.com"&gt;&lt;span style="background: SpringGreen;"&gt;san&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;diego&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;wedding&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;photographers&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Your first NHibernate based application</title><link>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/revision/10.aspx</link><pubDate>Thu, 18 Jun 2009 16:56:43 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:299</guid><dc:creator>SChalk</dc:creator><comments>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/comments.aspx</comments><description>Revision 10 posted to How to by SChalk on 18/06/2009 01:56:43 p.m.&lt;br /&gt;
&lt;h2&gt;Your first NHibernate based application&lt;/h2&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="color:#ff8000;"&gt;Wiki extracted from the original blog post of&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;a href="/members/gabriel.schenker/default.aspx"&gt;Gabriel&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;b&gt;Schenker&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;h4&gt;Welcome to NHibernate&lt;/h4&gt;
&lt;p&gt;If you&amp;#39;re reading this, we assume that you&amp;#39;ve just &lt;a href="/media/p/4.aspx"&gt;downloaded NHibernate&lt;/a&gt; and want to get started using it.&lt;/p&gt;
&lt;p&gt;This tutorial will talk you through the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installing NHibernate&lt;/li&gt;
&lt;li&gt;Defining a simple business object class.&lt;/li&gt;
&lt;li&gt;Create an NHibernate mapping to load and save the business object.&lt;/li&gt;
&lt;li&gt;Configure NHibernate to talk to your local database.&lt;/li&gt;
&lt;li&gt;Automatically generate a database&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Writing simple CRUD code using the Repository pattern.&lt;/li&gt;
&lt;li&gt;Using Unit Tests to make sure the code is working correctly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is what we&amp;#39;re aiming for:&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But first things first [:)]&lt;/p&gt;
&lt;p&gt;Lets start by actually doing something with that ZIP file you just downloaded.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;Installing NHibernate&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;If you&amp;#39;ve downloaded the NHibernate binaries in a zip file, all you need to do is extract that file to somewhere sensible. I usually create a folder called &amp;nbsp; &lt;code&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;c:\Code\Libraries\NHibernate&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;SharedLibs&lt;/span&gt;&amp;nbsp; &lt;code&gt;&lt;span style="background: SpringGreen;"&gt;c:\Code\SharedLibs\NHibernate&lt;/span&gt;&lt;/code&gt; and extract the zip to there. But whatever you&amp;#39;re comfortable with. This is your SharedLib folder from which you need to add your references to the NHibernate and NUnit dlls. Add references to NHibernate to both the demo project and the unit test project.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it! NHibernate is installed (easy huh). We&amp;#39;ll talk you through using it with Visual Studio in a moment. First let&amp;#39;s look at how we go about creating a project. Note this code is dependent on Visual Studio 2008 and .Net Framework 3.5.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;Create Your Project&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Before we start building our application and business objects, we&amp;#39;ll need to create a blank project to put them in. Fire up Visual Studio and create a new Class Library project. Let&amp;#39;s now look at something interesting: creating a business object.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Defining the Business Objects&lt;br /&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Lets start by defining a very simple domain. For the moment it consists of one entity called &lt;b&gt;Product&lt;/b&gt;. The product has 3 properties Name, Category and Discontinued.&lt;/p&gt;
&lt;p style="padding-left:210px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ProductDef.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Add a folder Domain to the FirstSample project of your solution. Add a new class &lt;b&gt;Product.cs&lt;/b&gt; to this folder. The code is very simple and uses automatic properties (a feature of the new C# 3.0 compiler) &lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now we want to be able to persist instances of this entity in a (relational) database. We have chosen &lt;b&gt;NHibernate&lt;/b&gt;for this task. An instance of an entity in the domain corresponds to a &lt;b&gt;row in a table&lt;/b&gt; in the database. So we have to define a mapping between the entity and the corresponding table in the database. This mapping can be done either by defining a mapping file (an xml-document) or by decorating the entity with attributes. I&amp;#39;ll start with the mapping file.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Define the Mapping&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Create a folder &lt;b&gt;Mappings&lt;/b&gt; in the FirstSample project. Add a new xml-document to this folder and call it &lt;b&gt;&lt;b&gt;Product&lt;/b&gt;.hbm.xml&lt;/b&gt;. Please note the &amp;quot;hbm&amp;quot; part of the file name. This is a convention used by NHibernate to automatically recognize the file as a mapping file. Define &amp;quot;Embedded Resource&amp;quot; as &lt;b&gt;Build Action&lt;/b&gt; for this xml file.&lt;/p&gt;
&lt;p&gt;In the Windows Explorer locate the nhibernate-mapping.xsd in the src folder of NHibernate and copy it to your SharedLibs folder. We can now use this xml schema definition file when defining our mapping files. VS will then provide intellisense and validation when editing an xml mapping document.&lt;/p&gt;
&lt;p&gt;Back in VS add the schema to the Product.hbm.xml file&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/properties.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s start now. Each mapping file has to define a &amp;lt;hibernate-mapping&amp;gt; root node&lt;/p&gt;
&lt;div id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:73647d35-a397-46d8-ad1c-a9edf8bbe509" class="wlWriterSmartContent"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;assembly&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;  &lt;span style="color:#008000;"&gt;&amp;lt;!-- more mapping info here --&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;In a mapping file when referencing a domain class you always have to provide the fully qualified name of the class (e.g. FirstSample.Domain.Product, FirstSample). To make the xml less verbose you can define the assembly name (in which the domain classes are implemented and the namespace of the domain classes in the two attributes &lt;b&gt;assembly&lt;/b&gt; and &lt;b&gt;namespace&lt;/b&gt; of the root node. It&amp;#39;s similar to the &lt;b&gt;using&lt;/b&gt; statement in C#.&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now we have to first define a &lt;b&gt;primary key&lt;/b&gt; for the product entity. Technically we could take the property &lt;b&gt;Name&lt;/b&gt; of the product since this property must be defined and has to be unique. But it is common to use a surrogate key instead. For thus we add a property to our entity and call it &lt;b&gt;Id&lt;/b&gt;. We use &lt;b&gt;Guid&lt;/b&gt; as the type of the Id but it can as well be an int or a long.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Guid Id { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The complete mapping file&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;assembly&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;class&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;id&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Id&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;generator&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;guid&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Name&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Category&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Discontinued&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;NHibernate doesn&amp;#39;t get in our way such as that it defines many reasonable defaults. So if you don&amp;#39;t provide a column name for a property explicitly it will name the column according to the property. Or NHibernate can automatically infer the name of the table or the type of the column from the class definition. As a consequence my xml mapping file is not cluttered with redundant information. Please refer to the online documentation for more detailed explanation of the mapping. You can find it &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Your solution explorer should look like this now (&lt;b&gt;Domain.cd&lt;/b&gt; contains the class diagram of our simple domain). You will have added the design folder and created the class diagram yourself although this is for good practice and not required for the purposes of this excercise.&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Configure NHibernate&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;We now have to tell NHibernate which database product we want to use and provide it the connection details in form of a connection string. NHibernate supports many many database products!&lt;/p&gt;
&lt;p&gt;Add a new xml file to the FirstSolution project and call it hibernate.cfg.xml. Set its property &amp;quot;&lt;b&gt;Copy to Output&lt;/b&gt;&amp;quot; to &amp;quot;&lt;b&gt;Copy always&lt;/b&gt;&amp;quot;. Since we are using SQL Server Compact Edition in this first sample enter the following information into the xml file&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-configuration&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-configuration-2.2&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;session-factory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.provider&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Connection.DriverConnectionProvider&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;dialect&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Dialect.MsSqlCeDialect&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.driver_class&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Driver.SqlServerCeDriver&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.connection_string&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;Data Source=FirstSample.sdf&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;show_sql&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;session-factory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;With this configuration file we tell NHibernate that we want to use MS SQL Server Compact Edition as our target database and that the name of the database shall be FirstSample.sdf (=connection string). We have also defined that we want to see the &lt;b&gt;SQL&lt;/b&gt; NHibernate generates and sends to the database (highly recommended for debugging purposes during development). Double check that you have no typos in the code!&lt;/p&gt;
&lt;p&gt;Add an empty database called &lt;b&gt;FirstSample.sdf&lt;/b&gt; to the FirstSample project (choose &lt;b&gt;Local Database&lt;/b&gt; as template)&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AddNewItem.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Click Add and ignore the DataSet creation wizard (just hit Cancel).&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Test the Setup&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;It&amp;#39;s now time to test our setup. First verify that you have the following files in your SharedLibs folder&lt;/p&gt;
&lt;p style="padding-left:180px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/SharedLibs.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The last 8 files you can find in the &amp;quot;&lt;b&gt;Microsoft SQL Server Compact Edition&lt;/b&gt;&amp;quot; directory in your Programs folder.&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/sqlce.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Note: the &lt;b&gt;System.Data.SqlServerCe.dll&lt;/b&gt; is located in the sub-folder &lt;b&gt;Desktop&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;All other files can be found in the NHibernate folder&lt;/p&gt;
&lt;p&gt;Add a reference to the FirstSample project in your test project. Additionally add references to NHibernate.dll, nunit.framework.dll and Systm.Data.SqlServerCe.dll (remember to reference the files located in the SharedLibs folder!). Pay attention to set the property &amp;quot;&lt;b&gt;Copy Local&lt;/b&gt;&amp;quot; to &lt;b&gt;true&lt;/b&gt; for the assembly System.Data.SqlServerCe.dll since by default it is set to false! Add a copy of hibernate.cfg.xml to the root of this unit test project. Direct action with NHibernate in the NUnit project needs access to this file.&lt;/p&gt;
&lt;p&gt;Add a class called &lt;b&gt;GenerateSchema_Fixture&lt;/b&gt; to your test project. Your test project should now look like this&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex1.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;We further need the 7 files sqce*.dll in the output directory. We can do this by using a post-build event in VS. Enter the following command in the &amp;quot;Post-build event command line&amp;quot;&lt;/p&gt;
&lt;p&gt;copy $(ProjectDir)..\..\SharedLibs\sqlce*.dll $(ProjectDir)$(OutDir)&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AppProperties.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now add the following code to the GenerateSchema_Fixture file&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:370px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; FirstSolution.Domain;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Cfg;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Tool.hbm2ddl;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NUnit.Framework;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Tests&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    [TestFixture]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; GenerateSchema_Fixture&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [Test]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_generate_schema()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            var cfg = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Configuration();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            cfg.Configure();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            cfg.AddAssembly(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt; (Product).Assembly);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SchemaExport(cfg).Execute(&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The first line of the test method creates a new instance of the NHibernate configuration class. This class is used to configure NHibernate. In the second line we tell NHibernate to configure itself. NHibernate will look out for configuration information since we do not provide any information here in the test method. So NHibernate will search for a file called &lt;b&gt;hibernate.cfg.xml&lt;/b&gt; in the output directory. That&amp;#39;s exactly what we want since we have defined our settings in this file.&lt;/p&gt;
&lt;p&gt;In the third line of the code we tell NHibernate that it can find mapping information in the assembly which contains also the class Product. At the time being it will only find one such file (Product.hbm.xml) as an embedded resource.&lt;/p&gt;
&lt;p&gt;The fourth line of code uses the SchemaExport helper class of NHibernate to auto-&amp;quot;magically&amp;quot; generate the schema in the database for us. SchemaExport will create the product table in the database and each time you call it it will delete the table and the table data and recreate it.&lt;/p&gt;
&lt;p&gt;Note: with this test method we do &lt;b&gt;NOT&lt;/b&gt; want to find out whether NHibernate does its job correctly (you can be sure it does) but rater whether we have setup our system correctly. However, you can check the database and see the newly created &amp;#39;product&amp;#39; table.&lt;/p&gt;
&lt;p&gt;If you have &lt;a href="http://www.testdriven.net/"&gt;TestDriven.Net&lt;/a&gt; installed you can now just right click inside the test method and choose &amp;quot;&lt;b&gt;Run Test(s)&lt;/b&gt;&amp;quot; to execute the test.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RunTest.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;If every thing is ok you should see the following result in the output window&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestResult.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;If you have &lt;a href="http://www.jetbrains.com/resharper/"&gt;ReSharper&lt;/a&gt; installed you can just start the test by clicking the yellow-green circle on the left border and choose &lt;b&gt;Run&lt;/b&gt;.&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSTestinfo.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The result is as follows&lt;/p&gt;
&lt;p style="padding-left:90px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSRunTest.png" alt="" /&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;In case of Problems&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;If your test fails double check that you find the following files in your target directory (that is: m:dev\projects\FirstSolution\src\FirstSolution.Tests\bin\debug)&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/InCaseOfPb.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Double check also if you have no typos in the NHibernate configuration file (hibernate.cfg.xml) or in the mapping file (Product.hbm.xml). Finally check whether you have set the &amp;quot;&lt;b&gt;Build Action&lt;/b&gt;&amp;quot; of the mapping file (Product.hbm.xml) to &amp;quot;&lt;b&gt;Embedded Resource&lt;/b&gt;&amp;quot;. Only continue if the test succeeds.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Our first CRUD operations&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Now obviously our system is ready to start. We have successfully implemented our Domain, defined the mapping files and configured NHibernate. Finally we have used NHibernate to automatically generate the database schema from our Domain (and our mapping files).&lt;/p&gt;
&lt;p&gt;In the spirit of DDD (see e.g. &lt;a href="http://domaindrivendesign.org/books/"&gt;Domain Driven Design&lt;/a&gt; by Eric Evans) we define a repository for all crud operations (create, read, update and delete). The repository interface is part of the domain where as the implementation is not! The implementation is infrastructure specific. We want to keep our domain persistence ignorant (PI).&lt;/p&gt;
&lt;p&gt;Add a new interface to the domain folder of our FirstSolution project. Call it IProductRepository. Let&amp;#39;s define the following interface&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;interface&lt;/span&gt; IProductRepository&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Add(Product product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Update(Product product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Remove(Product product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        Product GetById(Guid productId);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        Product GetByName(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; name);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        ICollection&amp;lt;Product&amp;gt; GetByCategory(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; category);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Add a class ProductRepository_Fixture to the test project of the solution and add the following code&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:270px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;[TestFixture]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; ProductRepository_Fixture&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; ISessionFactory _sessionFactory;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; Configuration _configuration;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [TestFixtureSetUp]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; TestFixtureSetUp()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            _configuration = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Configuration();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            _configuration.Configure();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            _configuration.AddAssembly(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt; (Product).Assembly);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            _sessionFactory = _configuration.BuildSessionFactory();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the fourth line of the method TestFixtureSetUp we create a session factory. This is an expensive process and should thus be executed only once. That&amp;#39;s the reason why I put it into this method which is only executed once during a test cycle.&lt;/p&gt;
&lt;p&gt;To keep our test methods side effect free we re-create our database schema before the execution of each test method. Thus we add the following method&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;[SetUp]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; SetupContext()&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SchemaExport(_configuration).Execute(&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And now we can implement the test method to add a new product instance to the database. Start by adding a new folder called Repositories to your &lt;b&gt;FirstSolution&lt;/b&gt; project. Add a class &lt;b&gt;ProductRepository&lt;/b&gt; to this folder. Make the&lt;b&gt;ProductRepository&lt;/b&gt; inherit from the interface &lt;b&gt;IProductRepository&lt;/b&gt;.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:652px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; FirstSolution.Domain;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Repositories&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; ProductRepository : IProductRepository&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Add(Product product)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Update(Product product)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Remove(Product product)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetById(Guid productId)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetByName(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; name)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; ICollection&amp;lt;Product&amp;gt; GetByCategory(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; category)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;Manipulating Data&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;Now go back to the ProductRepository_Fixture test class and implement the first test method&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;      [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_add_new_product()&lt;br /&gt;        {&lt;br /&gt;            var product = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;};&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            repository.Add(product);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The first run of the test method will fail since we have not yet implemented the &lt;b&gt;Add&lt;/b&gt; method in the repository class. Let&amp;#39;s do it. &lt;b&gt;But wait&lt;/b&gt;, we have to define a little helper class first which provides us session objects on demand.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:523px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; FirstSolution.Domain;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Cfg;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Repositories&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; NHibernateHelper&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; ISessionFactory _sessionFactory;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; ISessionFactory SessionFactory&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            get&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;(_sessionFactory == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    var configuration = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Configuration();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    configuration.Configure();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    configuration.AddAssembly(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Product).Assembly);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    _sessionFactory = configuration.BuildSessionFactory();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; _sessionFactory;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; ISession OpenSession()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; SessionFactory.OpenSession();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This class creates a session factory only the first time a client needs a new session.&lt;/p&gt;
&lt;p&gt;Now we can define the Add method in the ProductRepository as follows&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Add(Product product)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ITransaction transaction = session.BeginTransaction())&lt;br /&gt;                {&lt;br /&gt;                    session.Save(product);&lt;br /&gt;                    transaction.Commit();&lt;br /&gt;                }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The second run of the test method will again fail with the following message&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ShouldBeVirtual.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s because NHibernate is by default configured to use&lt;b&gt;&amp;nbsp;&lt;a href="http://martinfowler.com/eaaCatalog/lazyLoad.html"&gt;lazy load&lt;/a&gt;&lt;/b&gt; for all entities. That is the recommended approach and I warmly recommend not to change it for a maximum of flexibility.&lt;/p&gt;
&lt;p&gt;How can we solve this issue? It&amp;#39;s easy we have to just make all our properties (and methods) of the domain object(s) virtual. Let&amp;#39;s do this for our Product class&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; Guid Id { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now run the test again. It should succeed and we get the following output&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestOutput.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Note the sql spit out by NHibernate.&lt;/p&gt;
&lt;p&gt;Now we think that we have successfully inserted a new product into the database. But let&amp;#39;s test it whether it is really so. Let&amp;#39;s extend our test method&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:313px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [Test]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_add_new_product()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            var product = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;};&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            repository.Add(product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#008000;"&gt;// use session to try to load the product&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;(ISession session = _sessionFactory.OpenSession())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                var fromDb = session.Get&amp;lt;Product&amp;gt;(product.Id);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#008000;"&gt;// Test that the product was successfully inserted&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                Assert.IsNotNull(fromDb);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                Assert.AreNotSame(product, fromDb);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                Assert.AreEqual(product.Name, fromDb.Name);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                Assert.AreEqual(product.Category, fromDb.Category);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Run the test again. Hopefully it will succeed...&lt;/p&gt;
&lt;p&gt;Now we are ready to implement also the other methods of the repository. For testing this we would rather have a repository (that is database table) already containing some products. Nothing easier than this. Just add a method CreateInitialData to the test class as follows&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:355px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; Product[] _products = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;[]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Melon&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Pear&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Milk&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Coca Cola&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Pepsi Cola&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 };&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; CreateInitialData()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;(ISession session = _sessionFactory.OpenSession())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;(ITransaction transaction = session.BeginTransaction())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (var product &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; _products)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                        session.Save(product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    transaction.Commit();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Call this method from the SetupContext method (after the create schema call) and we are done. Now each time after the database schema is created the database is populated with some products.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s test the Update method of the repository with the following code&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [Test]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_update_existing_product()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            var product = _products[0];&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            product.Name = &lt;span style="color:#006080;"&gt;&amp;quot;Yellow Pear&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            repository.Update(product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#008000;"&gt;// use session to try to load the product&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = _sessionFactory.OpenSession())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                var fromDb = session.Get&amp;lt;Product&amp;gt;(product.Id);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                Assert.AreEqual(product.Name, fromDb.Name);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When running for the first time this code will fail since the Update method has not yet been implemented in the repository. &lt;b&gt;Note&lt;/b&gt;: This is the expected behavior since in TDD the first time you run a test it should always fail!&lt;/p&gt;
&lt;p&gt;Analogous to the Add method we implement the Update method of the repository. The only difference is that we call the update method of the NHibernate session object instead of the save method.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Update(Product product)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ITransaction transaction = session.BeginTransaction())&lt;br /&gt;            {&lt;br /&gt;                session.Update(product);&lt;br /&gt;                transaction.Commit();&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Run the test again an watch it succeed.&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestSucceed.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The delete method is straight forward. When testing whether the record has really been deleted we just assert that the value returned by the session&amp;#39;s get method is equal to null. Here is the test method&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:227px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_remove_existing_product()&lt;br /&gt;        {&lt;br /&gt;            var product = _products[0];&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            repository.Remove(product);&lt;br /&gt; &lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = _sessionFactory.OpenSession())&lt;br /&gt;            {&lt;br /&gt;                var fromDb = session.Get&amp;lt;Product&amp;gt;(product.Id);&lt;br /&gt;                Assert.IsNull(fromDb);&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and here the implementation of the Remove method in the repository&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Remove(Product product)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ITransaction transaction = session.BeginTransaction())&lt;br /&gt;                {&lt;br /&gt;                    session.Delete(product);&lt;br /&gt;                    transaction.Commit();&lt;br /&gt;                }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;Querying the Database&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;We still have to implement the three methods which query the database for objects. Let&amp;#39;s start with the most easy one, the GetById. First we write the test&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_get_existing_product_by_id()&lt;br /&gt;        {&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            var fromDb = repository.GetById(_products[1].Id);&lt;br /&gt;            Assert.IsNotNull(fromDb);&lt;br /&gt;            Assert.AreNotSame(_products[1], fromDb);&lt;br /&gt;            Assert.AreEqual(_products[1].Name, fromDb.Name);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and then the code to fulfill the test&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetById(Guid productId)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; session.Get&amp;lt;Product&amp;gt;(productId);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now that was easy. For the following two methods we use a new method of the session object. Let&amp;#39;s start with the GetByName method. As usual we write the test first&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_get_existing_product_by_name()&lt;br /&gt;        {&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            var fromDb = repository.GetByName(_products[1].Name);&lt;br /&gt; &lt;br /&gt;            Assert.IsNotNull(fromDb);&lt;br /&gt;            Assert.AreNotSame(_products[1], fromDb);&lt;br /&gt;            Assert.AreEqual(_products[1].Id, fromDb.Id);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The implementation of the GetByName method can be done by using two different approaches. The first is using HQL (Hibernate Query Language) and the second one HCQ (Hibernate Criteria Query). Let&amp;#39;s start with HQL. HQL is a object oriented query language similar (but not equal to) SQL.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To be added: implemetation of GetByName using HQL. Implement HCQ as below this works as expected and returns a product entity.&lt;/p&gt;
&lt;p&gt;In the above sample I have introduced a commonly used technique when using NHibernate. It&amp;#39;s called &lt;a href="http://en.wikipedia.org/wiki/Fluent_interface"&gt;fluent interfaces&lt;/a&gt;. As a result the code is less verbose and easier to understand. You can see that a HQL query is a string which can have embedded (named) parameters. Parameters are prefixed by a &amp;#39;:&amp;#39;. NHibernate defines many helper methods (like SetString used in the example) to assign values of various types to those parameters. Finally by using UniqueResult I tell NHibernate that I expect only one record to return. If more than one record is returned by the HQL query then an exception is raised. To get more information about HQL please read the &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/queryhql.html"&gt;online documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The second version uses a criteria query to search the requested product&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;reference&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt;&amp;nbsp; &lt;span style="background: SpringGreen;"&gt;NHibernate.Criterion&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;on&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;repository&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;page&lt;/span&gt;.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetByName(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; name)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;            {&lt;br /&gt;                Product product = session&lt;br /&gt;                    .CreateCriteria(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Product))&lt;br /&gt;                    .Add(Restrictions.Eq(&lt;span style="color:#006080;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;, name))&lt;br /&gt;                    .UniqueResult&amp;lt;Product&amp;gt;();&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; product;&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Many users of NHibernate think that this approach is more object oriented. On the other hand a complex query written with criteria syntax can quickly become difficult to understand.&lt;/p&gt;
&lt;p&gt;The last method to implement is GetByCategory. This method returns a list of products. The test can be implemented as follows&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:314px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_get_existing_products_by_category()&lt;br /&gt;        {&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            var fromDb = repository.GetByCategory(&lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;);&lt;br /&gt; &lt;br /&gt;            Assert.AreEqual(2, fromDb.Count);&lt;br /&gt;            Assert.IsTrue(IsInCollection(_products[0], fromDb));&lt;br /&gt;            Assert.IsTrue(IsInCollection(_products[1], fromDb));&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; IsInCollection(Product product, ICollection&amp;lt;Product&amp;gt; fromDb)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (var item &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; fromDb)&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (product.Id == item.Id)&lt;br /&gt;                    &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and the method itself might contain the following code&lt;/p&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; ICollection&amp;lt;Product&amp;gt; GetByCategory(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; category)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;            {&lt;br /&gt;                var products = session&lt;br /&gt;                    .CreateCriteria(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Product))&lt;br /&gt;                    .Add(Restrictions.Eq(&lt;span style="color:#006080;"&gt;&amp;quot;Category&amp;quot;&lt;/span&gt;, category))&lt;br /&gt;                    .List&amp;lt;Product&amp;gt;();&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; products;&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;h4&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;In this article I have shown you how to implement a basic sample domain, define the mapping to a database and how to configure NHibernate to be able to persist domain objects in the database. I have shown you how to typically write and test CRUD methods for your domain objects. I have taken MS SQL Compact Edition as sample database but any other supported database can be used (you only have to change the hibernate.cfg.xml file accordingly). Ee have no dependencies on external frameworks or tools other than the database and NHibernate itself (.NET of course never counts here).&lt;/p&gt;</description></item><item><title>Your first NHibernate based application</title><link>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/revision/9.aspx</link><pubDate>Thu, 18 Jun 2009 16:50:15 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:285</guid><dc:creator>SChalk</dc:creator><comments>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/comments.aspx</comments><description>Revision 9 posted to How to by SChalk on 18/06/2009 01:50:15 p.m.&lt;br /&gt;
&lt;h2&gt;Your first NHibernate based application&lt;/h2&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="color:#ff8000;"&gt;Wiki extracted from the original blog post of&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;a href="/members/gabriel.schenker/default.aspx"&gt;Gabriel&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;b&gt;Schenker&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;h4&gt;Welcome to NHibernate&lt;/h4&gt;
&lt;p&gt;If you&amp;#39;re reading this, we assume that you&amp;#39;ve just &lt;a href="/media/p/4.aspx"&gt;downloaded NHibernate&lt;/a&gt; and want to get started using it.&lt;/p&gt;
&lt;p&gt;This tutorial will talk you through the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installing NHibernate&lt;/li&gt;
&lt;li&gt;Defining a simple business object class.&lt;/li&gt;
&lt;li&gt;Create an NHibernate mapping to load and save the business object.&lt;/li&gt;
&lt;li&gt;Configure NHibernate to talk to your local database.&lt;/li&gt;
&lt;li&gt;Automatically generate a database&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Writing simple CRUD code using the Repository pattern.&lt;/li&gt;
&lt;li&gt;Using Unit Tests to make sure the code is working correctly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is what we&amp;#39;re aiming for:&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But first things first [:)]&lt;/p&gt;
&lt;p&gt;Lets start by actually doing something with that ZIP file you just downloaded.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;Installing NHibernate&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;If you&amp;#39;ve downloaded the NHibernate binaries in a zip file, all you need to do is extract that file to somewhere sensible. I usually create a folder called&amp;nbsp; &lt;code&gt;c:\Code\Libraries\NHibernate&lt;/code&gt; and extract the zip to there. But whatever you&amp;#39;re comfortable with. This is your SharedLib folder from which you need to add your references to the NHibernate and NUnit dlls. Add references to NHibernate to both the demo project and the unit test project.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it! NHibernate is installed (easy huh). We&amp;#39;ll talk you through using it with Visual Studio in a moment. First let&amp;#39;s look at how we go about creating a project. Note this code is dependent on Visual Studio 2008 and .Net Framework 3.5.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;Create Your Project&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Before we start building our application and business objects, we&amp;#39;ll need to create a blank project to put them in. Fire up Visual Studio and create a new Class Library project. Let&amp;#39;s now look at something interesting: creating a business object.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Defining the Business Objects&lt;br /&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Lets start by defining a very simple domain. For the moment it consists of one entity called &lt;b&gt;Product&lt;/b&gt;. The product has 3 properties Name, Category and Discontinued.&lt;/p&gt;
&lt;p style="padding-left:210px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ProductDef.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Add a folder Domain to the FirstSample project of your solution. Add a new class &lt;b&gt;Product.cs&lt;/b&gt; to this folder. The code is very simple and uses automatic properties (a feature of the new C# 3.0 compiler) &lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now we want to be able to persist instances of this entity in a (relational) database. We have chosen &lt;b&gt;NHibernate&lt;/b&gt;for this task. An instance of an entity in the domain corresponds to a &lt;b&gt;row in a table&lt;/b&gt; in the database. So we have to define a mapping between the entity and the corresponding table in the database. This mapping can be done either by defining a mapping file (an xml-document) or by decorating the entity with attributes. I&amp;#39;ll start with the mapping file.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Define the Mapping&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Create a folder &lt;b&gt;Mappings&lt;/b&gt; in the FirstSample project. Add a new xml-document to this folder and call it &lt;b&gt;&lt;b&gt;Product&lt;/b&gt;.hbm.xml&lt;/b&gt;. Please note the &amp;quot;hbm&amp;quot; part of the file name. This is a convention used by NHibernate to automatically recognize the file as a mapping file. Define &amp;quot;Embedded Resource&amp;quot; as &lt;b&gt;Build Action&lt;/b&gt; for this xml file.&lt;/p&gt;
&lt;p&gt;In the Windows Explorer locate the nhibernate-mapping.xsd in the src folder of NHibernate and copy it to your SharedLibs folder. We can now use this xml schema definition file when defining our mapping files. VS will then provide intellisense and validation when editing an xml mapping document.&lt;/p&gt;
&lt;p&gt;Back in VS add the schema to the Product.hbm.xml file&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/properties.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s start now. Each mapping file has to define a &amp;lt;hibernate-mapping&amp;gt; root node&lt;/p&gt;
&lt;div id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:73647d35-a397-46d8-ad1c-a9edf8bbe509" class="wlWriterSmartContent"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;assembly&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;  &lt;span style="color:#008000;"&gt;&amp;lt;!-- more mapping info here --&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;In a mapping file when referencing a domain class you always have to provide the fully qualified name of the class (e.g. FirstSample.Domain.Product, FirstSample). To make the xml less verbose you can define the assembly name (in which the domain classes are implemented and the namespace of the domain classes in the two attributes &lt;b&gt;assembly&lt;/b&gt; and &lt;b&gt;namespace&lt;/b&gt; of the root node. It&amp;#39;s similar to the &lt;b&gt;using&lt;/b&gt; statement in C#.&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now we have to first define a &lt;b&gt;primary key&lt;/b&gt; for the product entity. Technically we could take the property &lt;b&gt;Name&lt;/b&gt; of the product since this property must be defined and has to be unique. But it is common to use a surrogate key instead. For thus we add a property to our entity and call it &lt;b&gt;Id&lt;/b&gt;. We use &lt;b&gt;Guid&lt;/b&gt; as the type of the Id but it can as well be an int or a long.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Guid Id { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The complete mapping file&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;assembly&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;class&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;id&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Id&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;generator&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;guid&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Name&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Category&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Discontinued&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;NHibernate doesn&amp;#39;t get in our way such as that it defines many reasonable defaults. So if you don&amp;#39;t provide a column name for a property explicitly it will name the column according to the property. Or NHibernate can automatically infer the name of the table or the type of the column from the class definition. As a consequence my xml mapping file is not cluttered with redundant information. Please refer to the online documentation for more detailed explanation of the mapping. You can find it &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Your solution explorer should look like this now (&lt;b&gt;Domain.cd&lt;/b&gt; contains the class diagram of our simple domain). You will have added the design folder and created the class diagram yourself although this is for good practice and not required for the purposes of this excercise.&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Configure NHibernate&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;We now have to tell NHibernate which database product we want to use and provide it the connection details in form of a connection string. NHibernate supports many many database products!&lt;/p&gt;
&lt;p&gt;Add a new xml file to the FirstSolution project and call it hibernate.cfg.xml. Set its property &amp;quot;&lt;b&gt;Copy to Output&lt;/b&gt;&amp;quot; to &amp;quot;&lt;b&gt;Copy always&lt;/b&gt;&amp;quot;. Since we are using SQL Server Compact Edition in this first sample enter the following information into the xml file&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-configuration&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-configuration-2.2&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;session-factory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.provider&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Connection.DriverConnectionProvider&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;dialect&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Dialect.MsSqlCeDialect&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.driver_class&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Driver.SqlServerCeDriver&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.connection_string&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;Data Source=FirstSample.sdf&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;show_sql&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;session-factory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;With this configuration file we tell NHibernate that we want to use MS SQL Server Compact Edition as our target database and that the name of the database shall be FirstSample.sdf (=connection string). We have also defined that we want to see the &lt;b&gt;SQL&lt;/b&gt; NHibernate generates and sends to the database (highly recommended for debugging purposes during development). Double check that you have no typos in the code!&lt;/p&gt;
&lt;p&gt;Add an empty database called &lt;b&gt;FirstSample.sdf&lt;/b&gt; to the FirstSample project (choose &lt;b&gt;Local Database&lt;/b&gt; as template)&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AddNewItem.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Click Add and ignore the DataSet creation wizard (just hit Cancel).&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Test the Setup&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;It&amp;#39;s now time to test our setup. First verify that you have the following files in your SharedLibs folder&lt;/p&gt;
&lt;p style="padding-left:180px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/SharedLibs.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The last 8 files you can find in the &amp;quot;&lt;b&gt;Microsoft SQL Server Compact Edition&lt;/b&gt;&amp;quot; directory in your Programs folder.&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/sqlce.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Note: the &lt;b&gt;System.Data.SqlServerCe.dll&lt;/b&gt; is located in the sub-folder &lt;b&gt;Desktop&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;All other files can be found in the NHibernate folder&lt;/p&gt;
&lt;p&gt;Add a reference to the FirstSample project in your test project. Additionally add references to NHibernate.dll, nunit.framework.dll and Systm.Data.SqlServerCe.dll (remember to reference the files located in the SharedLibs folder!). Pay attention to set the property &amp;quot;&lt;b&gt;Copy Local&lt;/b&gt;&amp;quot; to &lt;b&gt;true&lt;/b&gt; for the assembly System.Data.SqlServerCe.dll since by default it is set to false! Add a copy of hibernate.cfg.xml to the root of this unit test project. Direct action with NHibernate in the NUnit project needs access to this file.&lt;/p&gt;
&lt;p&gt;Add a class called &lt;b&gt;GenerateSchema_Fixture&lt;/b&gt; to your test project. Your test project should now look like this&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex1.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;We further need the 7 files sqce*.dll in the output directory. We can do this by using a post-build event in VS. Enter the following command in the &amp;quot;Post-build event command line&amp;quot;&lt;/p&gt;
&lt;p&gt;copy $(ProjectDir)..\..\SharedLibs\sqlce*.dll $(ProjectDir)$(OutDir)&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AppProperties.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now add the following code to the GenerateSchema_Fixture file&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:370px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; FirstSolution.Domain;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Cfg;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Tool.hbm2ddl;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NUnit.Framework;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Tests&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    [TestFixture]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; GenerateSchema_Fixture&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [Test]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_generate_schema()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            var cfg = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Configuration();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            cfg.Configure();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            cfg.AddAssembly(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt; (Product).Assembly);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SchemaExport(cfg).Execute(&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The first line of the test method creates a new instance of the NHibernate configuration class. This class is used to configure NHibernate. In the second line we tell NHibernate to configure itself. NHibernate will look out for configuration information since we do not provide any information here in the test method. So NHibernate will search for a file called &lt;b&gt;hibernate.cfg.xml&lt;/b&gt; in the output directory. That&amp;#39;s exactly what we want since we have defined our settings in this file.&lt;/p&gt;
&lt;p&gt;In the third line of the code we tell NHibernate that it can find mapping information in the assembly which contains also the class Product. At the time being it will only find one such file (Product.hbm.xml) as an embedded resource.&lt;/p&gt;
&lt;p&gt;The fourth line of code uses the SchemaExport helper class of NHibernate to auto-&amp;quot;magically&amp;quot; generate the schema in the database for us. SchemaExport will create the product table in the database and each time you call it it will delete the table and the table data and recreate it.&lt;/p&gt;
&lt;p&gt;Note: with this test method we do &lt;b&gt;NOT&lt;/b&gt; want to find out whether NHibernate does its job correctly (you can be sure it does) but rater whether we have setup our system correctly. However, you can check the database and see the newly created &amp;#39;product&amp;#39; table.&lt;/p&gt;
&lt;p&gt;If you have &lt;a href="http://www.testdriven.net/"&gt;TestDriven.Net&lt;/a&gt; installed you can now just right click inside the test method and choose &amp;quot;&lt;b&gt;Run Test(s)&lt;/b&gt;&amp;quot; to execute the test.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RunTest.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;If every thing is ok you should see the following result in the output window&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestResult.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;If you have &lt;a href="http://www.jetbrains.com/resharper/"&gt;ReSharper&lt;/a&gt; installed you can just start the test by clicking the yellow-green circle on the left border and choose &lt;b&gt;Run&lt;/b&gt;.&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSTestinfo.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The result is as follows&lt;/p&gt;
&lt;p style="padding-left:90px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/RSRunTest.png" alt="" /&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;In case of Problems&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;If your test fails double check that you find the following files in your target directory (that is: m:dev\projects\FirstSolution\src\FirstSolution.Tests\bin\debug)&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/InCaseOfPb.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Double check also if you have no typos in the NHibernate configuration file (hibernate.cfg.xml) or in the mapping file (Product.hbm.xml). Finally check whether you have set the &amp;quot;&lt;b&gt;Build Action&lt;/b&gt;&amp;quot; of the mapping file (Product.hbm.xml) to &amp;quot;&lt;b&gt;Embedded Resource&lt;/b&gt;&amp;quot;. Only continue if the test succeeds.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Our first CRUD operations&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Now obviously our system is ready to start. We have successfully implemented our Domain, defined the mapping files and configured NHibernate. Finally we have used NHibernate to automatically generate the database schema from our Domain (and our mapping files).&lt;/p&gt;
&lt;p&gt;In the spirit of DDD (see e.g. &lt;a href="http://domaindrivendesign.org/books/"&gt;Domain Driven Design&lt;/a&gt; by Eric Evans) we define a repository for all crud operations (create, read, update and delete). The repository interface is part of the domain where as the implementation is not! The implementation is infrastructure specific. We want to keep our domain persistence ignorant (PI).&lt;/p&gt;
&lt;p&gt;Add a new interface to the domain folder of our FirstSolution project. Call it IProductRepository. Let&amp;#39;s define the following interface&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;interface&lt;/span&gt; IProductRepository&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Add(Product product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Update(Product product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Remove(Product product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        Product GetById(Guid productId);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        Product GetByName(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; name);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        ICollection&amp;lt;Product&amp;gt; GetByCategory(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; category);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Add a class ProductRepository_Fixture to the test project of the solution and add the following code&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:270px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;[TestFixture]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; ProductRepository_Fixture&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; ISessionFactory _sessionFactory;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; Configuration _configuration;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [TestFixtureSetUp]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; TestFixtureSetUp()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            _configuration = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Configuration();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            _configuration.Configure();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            _configuration.AddAssembly(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt; (Product).Assembly);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            _sessionFactory = _configuration.BuildSessionFactory();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the fourth line of the method TestFixtureSetUp we create a session factory. This is an expensive process and should thus be executed only once. That&amp;#39;s the reason why I put it into this method which is only executed once during a test &lt;span style="text-decoration: line-through; color: red;"&gt;cicle&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;cycle&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;To keep our test methods side effect free we re-create our database schema before the execution of each test method. Thus we add the following method&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;[SetUp]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; SetupContext()&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SchemaExport(_configuration).Execute(&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And now we can implement the test method to add a new product instance to the database. Start by adding a new folder called Repositories to your &lt;b&gt;FirstSolution&lt;/b&gt; project. Add a class &lt;b&gt;ProductRepository&lt;/b&gt; to this folder. Make the&lt;b&gt;ProductRepository&lt;/b&gt; inherit from the interface &lt;b&gt;IProductRepository&lt;/b&gt;.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:652px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; FirstSolution.Domain;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Repositories&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; ProductRepository : IProductRepository&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Add(Product product)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Update(Product product)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Remove(Product product)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetById(Guid productId)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetByName(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; name)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; ICollection&amp;lt;Product&amp;gt; GetByCategory(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; category)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;Manipulating Data&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;Now go back to the ProductRepository_Fixture test class and implement the first test method&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;      [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_add_new_product()&lt;br /&gt;        {&lt;br /&gt;            var product = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;};&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            repository.Add(product);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The first run of the test method will fail since we have not yet implemented the &lt;b&gt;Add&lt;/b&gt; method in the repository class. Let&amp;#39;s do it. &lt;b&gt;But wait&lt;/b&gt;, we have to define a little helper class first which provides us session objects on demand.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:523px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; FirstSolution.Domain;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Cfg;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Repositories&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; NHibernateHelper&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; ISessionFactory _sessionFactory;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; ISessionFactory SessionFactory&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            get&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;(_sessionFactory == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    var configuration = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Configuration();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    configuration.Configure();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                    configuration.AddAssembly(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Product).Assembly);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    _sessionFactory = configuration.BuildSessionFactory();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; _sessionFactory;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; ISession OpenSession()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; SessionFactory.OpenSession();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This class creates a session factory only the first time a client needs a new session.&lt;/p&gt;
&lt;p&gt;Now we can define the Add method in the ProductRepository as follows&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Add(Product product)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ITransaction transaction = session.BeginTransaction())&lt;br /&gt;                {&lt;br /&gt;                    session.Save(product);&lt;br /&gt;                    transaction.Commit();&lt;br /&gt;                }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The second run of the test method will again fail with the following message&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ShouldBeVirtual.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s because NHibernate is by default configured to use&lt;b&gt;&amp;nbsp;&lt;a href="http://martinfowler.com/eaaCatalog/lazyLoad.html"&gt;lazy load&lt;/a&gt;&lt;/b&gt; for all entities. That is the recommended approach and I warmly recommend not to change it for a maximum of flexibility.&lt;/p&gt;
&lt;p&gt;How can we solve this issue? It&amp;#39;s easy we have to just make all our properties (and methods) of the domain object(s) virtual. Let&amp;#39;s do this for our Product class&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; Guid Id { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;virtual&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now run the test again. It should succeed and we get the following output&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestOutput.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Note the sql spit out by NHibernate.&lt;/p&gt;
&lt;p&gt;Now we think that we have successfully inserted a new product into the database. But let&amp;#39;s test it whether it is really so. Let&amp;#39;s extend our test method&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:313px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [Test]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_add_new_product()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            var product = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;};&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            repository.Add(product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#008000;"&gt;// use session to try to load the product&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;(ISession session = _sessionFactory.OpenSession())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                var fromDb = session.Get&amp;lt;Product&amp;gt;(product.Id);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#008000;"&gt;// Test that the product was successfully inserted&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                Assert.IsNotNull(fromDb);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                Assert.AreNotSame(product, fromDb);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                Assert.AreEqual(product.Name, fromDb.Name);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                Assert.AreEqual(product.Category, fromDb.Category);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Run the test again. Hopefully it will succeed...&lt;/p&gt;
&lt;p&gt;Now we are ready to implement also the other methods of the repository. For testing this we would rather have a repository (that is database table) already containing some products. Nothing easier than this. Just add a method CreateInitialData to the test class as follows&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:355px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; Product[] _products = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;[]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Melon&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Pear&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Milk&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Coca Cola&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Product {Name = &lt;span style="color:#006080;"&gt;&amp;quot;Pepsi Cola&amp;quot;&lt;/span&gt;, Category = &lt;span style="color:#006080;"&gt;&amp;quot;Beverages&amp;quot;&lt;/span&gt;},&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                 };&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; CreateInitialData()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;(ISession session = _sessionFactory.OpenSession())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;(ITransaction transaction = session.BeginTransaction())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (var product &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; _products)&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                        session.Save(product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                    transaction.Commit();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Call this method from the SetupContext method (after the create schema call) and we are done. Now each time after the database schema is created the database is populated with some products.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s test the Update method of the repository with the following code&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:269px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [Test]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_update_existing_product()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            var product = _products[0];&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            product.Name = &lt;span style="color:#006080;"&gt;&amp;quot;Yellow Pear&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            repository.Update(product);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            &lt;span style="color:#008000;"&gt;// use session to try to load the product&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = _sessionFactory.OpenSession())&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;            {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;                var fromDb = session.Get&amp;lt;Product&amp;gt;(product.Id);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;                Assert.AreEqual(product.Name, fromDb.Name);&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            }&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When running for the first time this code will fail since the Update method has not yet been implemented in the repository. &lt;b&gt;Note&lt;/b&gt;: This is the expected behavior since in TDD the first time you run a test it should always fail!&lt;/p&gt;
&lt;p&gt;Analogous to the Add method we implement the Update method of the repository. The only difference is that we call the update method of the NHibernate session object instead of the save method.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Update(Product product)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ITransaction transaction = session.BeginTransaction())&lt;br /&gt;            {&lt;br /&gt;                session.Update(product);&lt;br /&gt;                transaction.Commit();&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Run the test again an watch it succeed.&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/TestSucceed.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The delete method is straight forward. When testing whether the record has really been deleted we just assert that the value returned by the session&amp;#39;s get method is equal to null. Here is the test method&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:227px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_remove_existing_product()&lt;br /&gt;        {&lt;br /&gt;            var product = _products[0];&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            repository.Remove(product);&lt;br /&gt; &lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = _sessionFactory.OpenSession())&lt;br /&gt;            {&lt;br /&gt;                var fromDb = session.Get&amp;lt;Product&amp;gt;(product.Id);&lt;br /&gt;                Assert.IsNull(fromDb);&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and here the implementation of the Remove method in the repository&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Remove(Product product)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ITransaction transaction = session.BeginTransaction())&lt;br /&gt;                {&lt;br /&gt;                    session.Delete(product);&lt;br /&gt;                    transaction.Commit();&lt;br /&gt;                }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h6&gt;&lt;b&gt;Querying the Database&lt;/b&gt;&lt;/h6&gt;
&lt;p&gt;We still have to implement the three methods which query the database for objects. Let&amp;#39;s start with the most easy one, the GetById. First we write the test&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_get_existing_product_by_id()&lt;br /&gt;        {&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            var fromDb = repository.GetById(_products[1].Id);&lt;br /&gt;            Assert.IsNotNull(fromDb);&lt;br /&gt;            Assert.AreNotSame(_products[1], fromDb);&lt;br /&gt;            Assert.AreEqual(_products[1].Name, fromDb.Name);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and then the code to fulfill the test&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetById(Guid productId)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; session.Get&amp;lt;Product&amp;gt;(productId);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now that was easy. For the following two methods we use a new method of the session object. Let&amp;#39;s start with the GetByName method. As usual we write the test first&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;       [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_get_existing_product_by_name()&lt;br /&gt;        {&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            var fromDb = repository.GetByName(_products[1].Name);&lt;br /&gt; &lt;br /&gt;            Assert.IsNotNull(fromDb);&lt;br /&gt;            Assert.AreNotSame(_products[1], fromDb);&lt;br /&gt;            Assert.AreEqual(_products[1].Id, fromDb.Id);&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The implementation of the GetByName method can be done by using two different approaches. The first is using HQL (Hibernate Query Language) and the second one HCQ (Hibernate Criteria Query). Let&amp;#39;s start with HQL. HQL is a object oriented query language similar (but not equal to) SQL&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;To&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;be&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;added&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;implemetation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;GetByName&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HQL&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Implement&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;HCQ&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;below&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;works&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;as&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;expected&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;returns&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;product&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;entity&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In the above sample I have introduced a commonly used technique when using NHibernate. It&amp;#39;s called &lt;a href="http://en.wikipedia.org/wiki/Fluent_interface"&gt;fluent interfaces&lt;/a&gt;. As a result the code is less verbose and easier to understand. You can see that a HQL query is a string which can have embedded (named) parameters. Parameters are prefixed by a &amp;#39;:&amp;#39;. NHibernate defines many helper methods (like SetString used in the example) to assign values of various types to those parameters. Finally by using UniqueResult I tell NHibernate that I expect only one record to return. If more than one record is returned by the HQL query then an exception is raised. To get more information about HQL please read the &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/queryhql.html"&gt;online documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The second version uses a criteria query to search the requested product.&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Product GetByName(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; name)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;            {&lt;br /&gt;                Product product = session&lt;br /&gt;                    .CreateCriteria(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Product))&lt;br /&gt;                    .Add(Restrictions.Eq(&lt;span style="color:#006080;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;, name))&lt;br /&gt;                    .UniqueResult&amp;lt;Product&amp;gt;();&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; product;&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Many users of NHibernate think that this approach is more object oriented. On the other hand a complex query written with criteria syntax can quickly become difficult to understand.&lt;/p&gt;
&lt;p&gt;The last method to implement is GetByCategory. This method returns a list of products. The test can be implemented as follows&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:314px;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        [Test]&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_get_existing_products_by_category()&lt;br /&gt;        {&lt;br /&gt;            IProductRepository repository = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ProductRepository();&lt;br /&gt;            var fromDb = repository.GetByCategory(&lt;span style="color:#006080;"&gt;&amp;quot;Fruits&amp;quot;&lt;/span&gt;);&lt;br /&gt; &lt;br /&gt;            Assert.AreEqual(2, fromDb.Count);&lt;br /&gt;            Assert.IsTrue(IsInCollection(_products[0], fromDb));&lt;br /&gt;            Assert.IsTrue(IsInCollection(_products[1], fromDb));&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; IsInCollection(Product product, ICollection&amp;lt;Product&amp;gt; fromDb)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (var item &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; fromDb)&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (product.Id == item.Id)&lt;br /&gt;                    &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and the method itself might contain the following code&lt;/p&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; ICollection&amp;lt;Product&amp;gt; GetByCategory(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; category)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; (ISession session = NHibernateHelper.OpenSession())&lt;br /&gt;            {&lt;br /&gt;                var products = session&lt;br /&gt;                    .CreateCriteria(&lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(Product))&lt;br /&gt;                    .Add(Restrictions.Eq(&lt;span style="color:#006080;"&gt;&amp;quot;Category&amp;quot;&lt;/span&gt;, category))&lt;br /&gt;                    .List&amp;lt;Product&amp;gt;();&lt;br /&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; products;&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;h4&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;In this article I have shown you how to implement a basic sample domain, define the mapping to a database and how to configure NHibernate to be able to persist domain objects in the database. I have shown you how to typically write and test CRUD methods for your domain objects. I have taken MS SQL Compact Edition as sample database but any other supported database can be used (you only have to change the hibernate.cfg.xml file accordingly). Ee have no dependencies on external frameworks or tools other than the database and NHibernate itself (.NET of course never counts here).&lt;/p&gt;</description></item><item><title>Your first NHibernate based application</title><link>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/revision/8.aspx</link><pubDate>Thu, 18 Jun 2009 16:45:17 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:284</guid><dc:creator>SChalk</dc:creator><comments>http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application/comments.aspx</comments><description>Revision 8 posted to How to by SChalk on 18/06/2009 01:45:17 p.m.&lt;br /&gt;
&lt;h2&gt;Your first NHibernate based application&lt;/h2&gt;
&lt;h4&gt;&lt;b&gt;&lt;span style="color:#ff8000;"&gt;Wiki extracted from the original blog post of&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;a href="/members/gabriel.schenker/default.aspx"&gt;Gabriel&amp;nbsp;&lt;span style="font-weight:normal;"&gt;&lt;b&gt;Schenker&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;h4&gt;Welcome to NHibernate&lt;/h4&gt;
&lt;p&gt;If you&amp;#39;re reading this, we assume that you&amp;#39;ve just &lt;a href="/media/p/4.aspx"&gt;downloaded NHibernate&lt;/a&gt; and want to get started using it.&lt;/p&gt;
&lt;p&gt;This tutorial will talk you through the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installing NHibernate&lt;/li&gt;
&lt;li&gt;Defining a simple business object class.&lt;/li&gt;
&lt;li&gt;Create an NHibernate mapping to load and save the business object.&lt;/li&gt;
&lt;li&gt;Configure NHibernate to talk to your local database.&lt;/li&gt;
&lt;li&gt;Automatically generate a database&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Writing simple CRUD code using the Repository pattern.&lt;/li&gt;
&lt;li&gt;Using Unit Tests to make sure the code is working correctly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is what we&amp;#39;re aiming for:&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But first things first [:)]&lt;/p&gt;
&lt;p&gt;Lets start by actually doing something with that ZIP file you just downloaded.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;Installing NHibernate&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;If you&amp;#39;ve downloaded the NHibernate binaries in a zip file, all you need to do is extract that file to somewhere sensible. I usually create a folder called&amp;nbsp; &lt;code&gt;c:\Code\Libraries\NHibernate&lt;/code&gt; and extract the zip to there. But whatever you&amp;#39;re comfortable with. &lt;span style="background: SpringGreen;"&gt;This&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SharedLib&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;from&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;which&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;you&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;your&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;references&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NUnit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;dlls&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;references&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;both&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;demo&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;unit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it! NHibernate is installed (easy huh). We&amp;#39;ll talk you through using it with Visual Studio in a moment. First let&amp;#39;s look at how we go about creating a project&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Note&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;code&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;dependent&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;on&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Visual&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Studio&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;2008&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Net&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Framework&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;3.5&lt;/span&gt;.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;&lt;b&gt;Create Your Project&lt;/b&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Before we start building our application and business objects, we&amp;#39;ll need to create a blank project to put them in. Fire up Visual Studio and create a new Class Library project. Let&amp;#39;s now look at something interesting: creating a business object.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Defining the Business Objects&lt;br /&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Lets start by defining a very simple domain. For the moment it consists of one entity called &lt;b&gt;Product&lt;/b&gt;. The product has 3 properties Name, Category and Discontinued.&lt;/p&gt;
&lt;p style="padding-left:210px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/ProductDef.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Add a folder Domain to the FirstSample project of your solution. Add a new class &lt;b&gt;Product.cs&lt;/b&gt; to this folder. The code is very simple and uses automatic properties (a feature of the new C# 3.0 compiler) &lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now we want to be able to persist instances of this entity in a (relational) database. We have chosen &lt;b&gt;NHibernate&lt;/b&gt;for this task. An instance of an entity in the domain corresponds to a &lt;b&gt;row in a table&lt;/b&gt; in the database. So we have to define a mapping between the entity and the corresponding table in the database. This mapping can be done either by defining a mapping file (an xml-document) or by decorating the entity with attributes. I&amp;#39;ll start with the mapping file.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Define the Mapping&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;Create a folder &lt;b&gt;Mappings&lt;/b&gt; in the FirstSample project. Add a new xml-document to this folder and call it &lt;b&gt;&lt;b&gt;Product&lt;/b&gt;.hbm.xml&lt;/b&gt;. Please note the &amp;quot;hbm&amp;quot; part of the file name. This is a convention used by NHibernate to automatically recognize the file as a mapping file. Define &amp;quot;Embedded Resource&amp;quot; as &lt;b&gt;Build Action&lt;/b&gt; for this xml file.&lt;/p&gt;
&lt;p&gt;In the Windows Explorer locate the nhibernate-mapping.xsd in the src folder of NHibernate and copy it to your SharedLibs folder. We can now use this xml schema definition file when defining our mapping files. VS will then provide intellisense and validation when editing an xml mapping document.&lt;/p&gt;
&lt;p&gt;Back in VS add the schema to the Product.hbm.xml file&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/properties.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s start now. Each mapping file has to define a &amp;lt;hibernate-mapping&amp;gt; root node&lt;/p&gt;
&lt;div id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:73647d35-a397-46d8-ad1c-a9edf8bbe509" class="wlWriterSmartContent"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;assembly&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;  &lt;span style="color:#008000;"&gt;&amp;lt;!-- more mapping info here --&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;In a mapping file when referencing a domain class you always have to provide the fully qualified name of the class (e.g. FirstSample.Domain.Product, FirstSample). To make the xml less verbose you can define the assembly name (in which the domain classes are implemented and the namespace of the domain classes in the two attributes &lt;b&gt;assembly&lt;/b&gt; and &lt;b&gt;namespace&lt;/b&gt; of the root node. It&amp;#39;s similar to the &lt;b&gt;using&lt;/b&gt; statement in C#.&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now we have to first define a &lt;b&gt;primary key&lt;/b&gt; for the product entity. Technically we could take the property &lt;b&gt;Name&lt;/b&gt; of the product since this property must be defined and has to be unique. But it is common to use a surrogate key instead. For thus we add a property to our entity and call it &lt;b&gt;Id&lt;/b&gt;. We use &lt;b&gt;Guid&lt;/b&gt; as the type of the Id but it can as well be an int or a long.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Domain&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Product&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Guid Id { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Category { get; set; }&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Discontinued { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The complete mapping file&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-mapping-2.2&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;assembly&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color:#ff0000;"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;FirstSolution.Domain&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;class&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;id&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Id&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;generator&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;guid&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Name&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Category&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Discontinued&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;NHibernate doesn&amp;#39;t get in our way such as that it defines many reasonable defaults. So if you don&amp;#39;t provide a column name for a property explicitly it will name the column according to the property. Or NHibernate can automatically infer the name of the table or the type of the column from the class definition. As a consequence my xml mapping file is not cluttered with redundant information. Please refer to the online documentation for more detailed explanation of the mapping. You can find it &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Your solution explorer should look like this now (&lt;b&gt;Domain.cd&lt;/b&gt; contains the class diagram of our simple &lt;span style="text-decoration: line-through; color: red;"&gt;domain&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;domain)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;have&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;added&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;design&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;folder&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;created&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;class&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;diagram&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;yourself&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;although&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;good&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;practice&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;not&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;required&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;for&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;purposes&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;excercise&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:150px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex.png" alt="" /&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Configure NHibernate&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;We now have to tell NHibernate which database product we want to use and provide it the connection details in form of a connection string. NHibernate supports many many database products!&lt;/p&gt;
&lt;p&gt;Add a new xml file to the FirstSolution project and call it hibernate.cfg.xml. Set its property &amp;quot;&lt;b&gt;Copy to Output&lt;/b&gt;&amp;quot; to &amp;quot;&lt;b&gt;Copy always&lt;/b&gt;&amp;quot;. Since we are using SQL Server Compact Edition in this first sample enter the following information into the xml file&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#800000;"&gt;xml&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-configuration&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;urn:nhibernate-configuration-2.2&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;session-factory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.provider&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Connection.DriverConnectionProvider&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;dialect&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Dialect.MsSqlCeDialect&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.driver_class&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;NHibernate.Driver.SqlServerCeDriver&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;connection.connection_string&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;Data Source=FirstSample.sdf&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;show_sql&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;session-factory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;hibernate-configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;With this configuration file we tell NHibernate that we want to use MS SQL Server Compact Edition as our target database and that the name of the database shall be FirstSample.sdf (=connection string). We have also defined that we want to see the &lt;b&gt;SQL&lt;/b&gt; NHibernate generates and sends to the database (highly recommended for debugging purposes during development). Double check that you have no typos in the code!&lt;/p&gt;
&lt;p&gt;Add an empty database called &lt;b&gt;FirstSample.sdf&lt;/b&gt; to the FirstSample project (choose &lt;b&gt;Local Database&lt;/b&gt; as template)&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AddNewItem.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Click Add and ignore the DataSet creation wizard (just hit Cancel).&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Test the Setup&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;It&amp;#39;s now time to test our setup. First verify that you have the following files in your SharedLibs folder&lt;/p&gt;
&lt;p style="padding-left:180px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/SharedLibs.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The last 8 files you can find in the &amp;quot;&lt;b&gt;Microsoft SQL Server Compact Edition&lt;/b&gt;&amp;quot; directory in your Programs folder.&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/sqlce.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Note: the &lt;b&gt;System.Data.SqlServerCe.dll&lt;/b&gt; is located in the sub-folder &lt;b&gt;Desktop&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;All other files can be found in the NHibernate folder&lt;/p&gt;
&lt;p&gt;Add a reference to the FirstSample project in your test project. Additionally add references to NHibernate.dll, nunit.framework.dll and Systm.Data.SqlServerCe.dll (remember to reference the files located in the SharedLibs folder!). Pay attention to set the property &amp;quot;&lt;b&gt;Copy Local&lt;/b&gt;&amp;quot; to &lt;b&gt;true&lt;/b&gt; for the assembly System.Data.SqlServerCe.dll since by default it is set to false! Add a &lt;span style="background: SpringGreen;"&gt;copy&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;hibernate.cfg.xml&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;root&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;of&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;unit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;test&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Direct&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;action&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;with&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NUnit&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;project&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;needs&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;access&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;this&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;file&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;Add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;a&lt;/span&gt; class called &lt;b&gt;GenerateSchema_Fixture&lt;/b&gt; to your test project. Your test project should now look like this&lt;/p&gt;
&lt;p style="padding-left:120px;"&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/solutionex1.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;We further need the 7 files sqce*.dll in the output directory. We can do this by using a post-build event in VS. Enter the following command in the &amp;quot;Post-build event command line&amp;quot;&lt;/p&gt;
&lt;p&gt;copy $(ProjectDir)..\..\SharedLibs\sqlce*.dll $(ProjectDir)$(OutDir)&lt;/p&gt;
&lt;p&gt;&lt;img src="/cfs-file.ashx/__key/CommunityServer.Wikis.Components.Files/howtonh/AppProperties.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now add the following code to the GenerateSchema_Fixture file&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;max-height:200px;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;height:370px;background-color:#f4f4f4;"&gt;
&lt;div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; FirstSolution.Domain;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Cfg;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NHibernate.Tool.hbm2ddl;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; NUnit.Framework;&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;namespace&lt;/span&gt; FirstSolution.Tests&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;{&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    [TestFixture]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; GenerateSchema_Fixture&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        [Test]&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Can_generate_schema()&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:white;"&gt;        {&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;            var cfg = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Configuration();&lt;/pre&gt;
&lt;pre style="border-style:none;margin:0em;p