Corey Coogan

Python, .Net, C#, ASP.NET MVC, Architecture and Design

  • Subscribe

  • Archives

  • Blog Stats

    • 110,056 hits
  • Meta

Posts Tagged ‘Fluent Nhibernate’

Asp.Net MVC, S#arp Architecture and Blood

Posted by coreycoogan on September 5, 2009


The Bleeding Edge

The Bleeding Edge

As mentioned in a previous post, I’ve embarked on a side project that provides tangible value to a relatively large mass of people.  This project, http://www.roomparentsonline.com, started some time ago and seemed like the perfect opportunity to move from toying with ASP.NET MVC and NHibernate to actually writing a production app with those tools.  Had I stuck with the same old stack I’m sure the project would be done by now, but instead I’m just getting started with developing actual features.  This is a very similar situation described in Rob Conery’s latest post, but I’m listening to Bad Corey and forging ahead because I really want to up my skills in this area.

So where was all my time spent?  Some was dedicated towards getting the design I got from Mark Sternig into the MVC framework.  Other time was spent getting the membership stuff setup and figuring out how I was going to lay all that out, but the other 90% was spent with Fluent NHibernate (FNH) and getting slashed by the bleeding edge of every cool OSS project out there.  Now I know why a common Alt.Net slogan is “Running with Scissors”.

S#arp Archecture 1.0 RTM

My first major hurdle was caused by the fact that I didn’t want to wait anymore for SharpArch to be released in 1.0, so I moved ahead with the latest.  I already had some significant development done when 1.0 was released 10 days later.  The RTM release was significant and fixed many issues, but there’s no way to simply upgrade the templates.  So I started by copying over all the 1.0 binaries, which caused some compatibility issues because dependencies were built against previous versions of Castle, NHibernate, etc.  I began upgrading bit by bit and found the updated classes in the new template and began to upgrade my project.  It was painful, but in the end it worked and all was good.  Time to move on to getting some mappings done.

Fluent NHibernate

For those of you not familiar with what Fluent NHibernate is, it basically lets you configure NHibernate through a fluent interface without requiring XML files.  I personally hate configuring with XML files, which is why I was so intrigued by this project.  The example project and articles I’ve read make FNH seem so simple.  It was only after I began to dive deep that I realized it seemed simple because the examples were simple.  When I tried doing things like mapping table-per-hierarchy relationships, I started pulling my hair out.  Things just didn’t work as I expected them to.  So I began to post to the FNH Group and got some great help, mostly from the creator himself, James Gregory.  Much of the advice was the same – get latest from the trunk as odds were this was a bug that’s already been fixed.

This is where the fun began.  Upgrading to FNH from the trunk meant upgrading NHibernate, meant upgrading multiple Castle projects, meant upgrading NHiberate Validator meant upgrading xVal meant upgrading all core Sharp Architecture libraries.  As you can imagine, this was going to be painful, but I saw no other option.  To make matters worse, the version from the trunk had many breaking changes so I was also breaking stuff that I actually had working.  Thankfully, Tom Cabanski informed the SharpArch group that he had rebuilt all the binaries against these latest versions and provided them in a tidy little zip file.  This was a huge help and I can’t thank Tom enough.

The Future

I’m now at a place where I can begin to actually implement features.  I’ve said a sad goodbye to my self-imposed deadline of having this app, at least registration, done by start of the 2009 school year, but I’ve learned a lot and have much more to learn.  During the upgrade process, I was also able to move to the 1.0 release of Linq to NHibernate.  It’s wonderful to think how many great projects came to fruition this summer after reading about them in their idea phase for so long.  The .NET OSS community is strong and I’m grateful to be enjoying the fruits of their labor.  Anyway, I finally figured out how to blend automappings and Fluent mappings, which was required to do class-per-hierarchy, but I’ll save that for another post.  I also have a nice validation implementation utilizing NHibernate Validator, JQuery Validation and xVal, but that post is coming as well.

Advertisements

Posted in ASP.NET MVC, Fluent Nhibernate, NHibernate, S#arp Architecture | Tagged: , , , , , , | 5 Comments »