views:

24

answers:

1

I'm working on a project to replace ADO.NET data access logic using NHibernate where we're not able to map the entire domain model at once. This means we'll have domain classes with property mappings to other domain classes that aren't yet mapped with NHibernate.

Consider a Person class with an Address property (Address being a domain object without an NH mapping and Person being the class I'm mapping). How can I include Address in the Person mapping without creating an entire mapping for Address?

Is it possible to call legacy (ADO.NET) data access logic from a custom PropertyAccessor? If so, is it reasonable?

*I asked this within another question here but didn't get a response. I'm hoping to get one in a more concise question.

+1  A: 

In your example even if you didn't create a mapping file for Address, it would potentially be as much work as creating the mapping file itself. There are a some other options you may consider during your transition, like have a custom DAL with a method 'GetPerson', for example, that would NH load person and ADO load address. Not pretty or efficient, but encapsulates the work, so the interface doesn't change when you want to map Address. That being said there are some options for creating custom data tranforms using NHibernate.Transform.AliasToBeanResultTransformer. But really in the end you have to find a good way to chunk out pieces of your domain model. Using a DAL is both good practice and can be a decent bridge out of ADO and into the NH madness.

Trent