views:

288

answers:

1

We've been looking at using an ORM at work.

Currently we are trying to way up the pro's and con's of fluent nhibernate against castle active record.

We are unsure of the flexibility of each as our database isn't very conventional. It lacks foreign keys and identities on the primary keys (A little confusing but the next value is stored in a seperate table). Also there are a few situations where we have table names suffix'd by the year. We then select from one depending on the year. This could obviously be a little trickier.

I've currently managed to sort the foreign key mapping using castle and also the primary key generation by create a custom class.

Does any one have any opnions on either of these frameworks and or ideas of how to solve these problems with either.

Ps. please don't ask us to refactor the database. Its not an option at the moment.

Thanks.

+4  A: 

FluentNHibernate and ActiveRecord are quite different. The first one is just codified, convention driven mapping generator for NHibernate. The latter is a layer of abstraction on top of NHibernate along with implementation of the Active Record pattern.

Castle Active Record does hide certain aspects of NHibernate from you, taking care of some things by itself. As such it may be less flexible option if you already have a convoluted existing database.

FluentNHibernate just generates your mappings and you use NHibernate directly all the time to interact with your database.

So while I'm not the expert in any of these, I'd say for such convoluted DB you want to stay as close to the metal as possible, so perhaps bare NHibernate (mapped via FluentNHibernate or hbms where required), or even IBatis.NET would be a better option for you.

Where ActiveRecord shines, is when you start your project from scratch, with no legacy DB.

Krzysztof Koźmic
+1 if you have an existing legacy DB, NH is the way to go.
mxmissile
I'm inclined to agree but I still like Active Record. Maybe its the ruby in me
mjmcloug