<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Annoyed.ca &#187; Fluent NHibernate</title>
	<atom:link href="http://annoyed.ca/category/technology/net/nhibernate/fluent-nhibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://annoyed.ca</link>
	<description>Life - Technology</description>
	<lastBuildDate>Fri, 30 Mar 2012 21:58:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Defining Access Strategy in FluentNHibernate</title>
		<link>http://annoyed.ca/2009/01/05/defining-access-strategy-in-fluentnhibernate/</link>
		<comments>http://annoyed.ca/2009/01/05/defining-access-strategy-in-fluentnhibernate/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 02:57:02 +0000</pubDate>
		<dc:creator>Christopher Hyne</dc:creator>
				<category><![CDATA[Fluent NHibernate]]></category>

		<guid isPermaLink="false">http://annoyed.ca/2009/01/05/defining-access-strategy-in-fluentnhibernate/</guid>
		<description><![CDATA[I am posting this because it took me a little while (longer than it should have) to figure out how to define the access strategy for an domain object&#8217;s fields or properties. The documentation for FluentNHibernate is still fairly basic, &#8230; <a href="http://annoyed.ca/2009/01/05/defining-access-strategy-in-fluentnhibernate/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am posting this because it took me a little while (longer than it should have) to figure out how to define the access strategy for an domain object&#8217;s fields or properties. The documentation for FluentNHibernate is still fairly basic, and Googling for the answer didn&#8217;t get me anywhere. In the end I figured it out from Visual Studio&#8217;s intellisense (which frankly is where I should have looked in the first place).</p>
<p>For all those like me who decide to Google first, here is the answer.</p>
<p>A number of the *Part classes in the FluentNHibernate.Mapping namespace implement the IAccessStrategy(Of ComponentPart(Of T)) interface. This interface defines one property, Access which returns an AccessStrategyBuilder(Of T) object. The AccessStrategyBuilder object has a number of methods used to define the access strategy:</p>
<ul>
<li>AsCamelCaseField
<li>AsField
<li>AsLowerCaseField
<li>AsPascalCaseField
<li>AsProperty
<li>AsReadOnlyPropertyThroughCamelCaseField
<li>AsReadOnlyPropertyThroughLowerCaseField
<li>AsReadOnlyPropertyThroughPascalCaseField</li>
</ul>
<p>This information I found relatively quickly. What I was missing was how to specify that my camel case fields are prefixed with the underscore character. But all of the CamelCase, LowerCase and PascalCase variations of the methods listed above have an overload which accepts an instance of a Prefix object, of which there are 4 variations:</p>
<ul>
<li>m
<li>mUnderscore
<li>None
<li>Underscore</li>
</ul>
<p>So in the end, my mapping is as follows:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">WithTable(<span style="color: #006080">"client"</span>)

Id(<span style="color: #0000ff">Function</span>(c) c.ID, <span style="color: #006080">"id"</span>).WithUnsavedValue(0).GeneratedBy.Identity()

Map(<span style="color: #0000ff">Function</span>(c) c.AccountName).TheColumnNameIs(<span style="color: #006080">"account_name"</span>)
Map(<span style="color: #0000ff">Function</span>(c) c.Company).TheColumnNameIs(<span style="color: #006080">"company"</span>)
Map(<span style="color: #0000ff">Function</span>(c) c.Created).TheColumnNameIs(<span style="color: #006080">"created"</span>)
Map(<span style="color: #0000ff">Function</span>(c) c.Updated).TheColumnNameIs(<span style="color: #006080">"updated"</span>)
Map(<span style="color: #0000ff">Function</span>(c) c.UseAdministrativeContactAsBillingContact).TheColumnNameIs(<span style="color: #006080">"blg_is_adm"</span>)

Component(Of Client)(<span style="color: #0000ff">Function</span>(c) c.AdministrativeContact, _
                     <span style="color: #0000ff">AddressOf</span> MapAdministrativeContact).Access.AsCamelCaseField(Prefix.Underscore)
Component(Of Client)(<span style="color: #0000ff">Function</span>(c) c.BillingContact, _
                     <span style="color: #0000ff">AddressOf</span> MapBillingContact).Access.AsCamelCaseField(Prefix.Underscore)</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://annoyed.ca/2009/01/05/defining-access-strategy-in-fluentnhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>S#arp Architecture</title>
		<link>http://annoyed.ca/2008/12/19/sarp-architecture/</link>
		<comments>http://annoyed.ca/2008/12/19/sarp-architecture/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 03:57:18 +0000</pubDate>
		<dc:creator>Christopher Hyne</dc:creator>
				<category><![CDATA[ASP.Net MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Fluent NHibernate]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Rhino Mocks]]></category>
		<category><![CDATA[S#arp Architecture]]></category>
		<category><![CDATA[VB.Net]]></category>

		<guid isPermaLink="false">http://annoyed.ca/2008/12/19/sarp-architecture/</guid>
		<description><![CDATA[I&#8217;ve been poking around in the latest release of the S#arp Architecture over the last couple days. I like what I see. Pronounced &#8220;Sharp Architecture,&#8221; this is a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET &#8230; <a href="http://annoyed.ca/2008/12/19/sarp-architecture/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been poking around in the latest release of the <a href="http://code.google.com/p/sharp-architecture/" target="_blank">S#arp Architecture</a> over the last couple days. I like what I see.</p>
<blockquote><p>Pronounced &#8220;Sharp Architecture,&#8221; this is a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate.</p>
</blockquote>
<p>This evening I took about an hour and converted the basic starter solution template from C# to VB.Net. Why? Well, for the following reasons:</p>
<ol>
<li>While I can work with C# well enough, I&#8217;m much more familiar with VB.Net, which I am required to use at my 9 to 5 job. I tend to stick with VB.Net even for my personal projects for simplicity. Anything I learn on my own I can easily apply at work.</li>
<li>It gave me an opportunity to confirm that I understand (at least at a high level) what the S#arp Architecture is doing.</li>
</ol>
<p>The conversion was straight forward. Pretty well every line of C# had a corresponding line in VB.Net. The only thing I had to add was an Imports tag in the markup of the Site.Master page in order to get the ActionLink and Image extension methods to resolve. I had already tried adding an imports to the code-behind with no luck. Not sure why that was necessary, but it worked.</p>
<p>The architecture is pretty neat. Here&#8217;s a few things I&#8217;ve noted already:</p>
<ul>
<li>The Models, Views and Controllers (I.e. the M, V and C in MVC) are each in their own projects.</li>
<li>The Repository/IRepository pattern is used, with the Interfaces defined in the same project as the Models, and the Repository implementation(s) in a separate project.</li>
<li>Includes support for NUnit, Castle Windsor, (Fluent) NHibernate, and Rhino Mocks</li>
<li>The ASP.Net MVC routes are defined in the Controllers project, not in the Global.asax of the Web/Views project. Excellent separation of concerns!</li>
</ul>
<p>I&#8217;m going to go ahead and trying putting together an actual application based on S#arp Architecture.</p>
]]></content:encoded>
			<wfw:commentRss>http://annoyed.ca/2008/12/19/sarp-architecture/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

