Welcome!
I am a .Net developer by day; a PHP developer, Linux systems administrator and small business owner by night and a husband and father 24/7/365!
This is my blog about technology and my life in general!
On January 05, 2009 in Fluent NHibernate
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’s fields or properties. The documentation for FluentNHibernate is still fairly basic, and Googling for the answer didn’t get me anywhere. In the end I figured it out from Visual Studio’s intellisense (which frankly is where I should have looked in the first place).
For all those like me who decide to Google first, here is the answer.
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:
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:
So in the end, my mapping is as follows:
WithTable("client") Id(Function(c) c.ID, "id").WithUnsavedValue(0).GeneratedBy.Identity() Map(Function(c) c.AccountName).TheColumnNameIs("account_name") Map(Function(c) c.Company).TheColumnNameIs("company") Map(Function(c) c.Created).TheColumnNameIs("created") Map(Function(c) c.Updated).TheColumnNameIs("updated") Map(Function(c) c.UseAdministrativeContactAsBillingContact).TheColumnNameIs("blg_is_adm") Component(Of Client)(Function(c) c.AdministrativeContact, _ AddressOf MapAdministrativeContact).Access.AsCamelCaseField(Prefix.Underscore) Component(Of Client)(Function(c) c.BillingContact, _ AddressOf MapBillingContact).Access.AsCamelCaseField(Prefix.Underscore)
On December 19, 2008 in ASP.Net MVC, C#, Fluent NHibernate, NUnit, Rhino Mocks, S#arp Architecture, VB.Net
I’ve been poking around in the latest release of the S#arp Architecture over the last couple days. I like what I see.
Pronounced “Sharp Architecture,” this is a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate.
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:
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.
The architecture is pretty neat. Here’s a few things I’ve noted already:
I’m going to go ahead and trying putting together an actual application based on S#arp Architecture.