views:

37

answers:

1

I'm attempting to work with a legacy system which already has well-defined domain objects. I would like to use NHibernate as the ORM for some of these objects, but since I cannot modify the objects to allow their methods to be overridden by NHibernate, normal techniques for lazy-loaded objects wont be viable.

Are there any alternative approaches I can take to allow the objects to be used without modification to them, but will still allow me to load only a portion of the associations on an object?

+1  A: 

It might or might not work, dependending on how specifically are these objects coded. I wouldn't even try to map them directly, it's probably going to be a PITA because it's too limiting. Instead, just create other classes to work with NHibernate.

Mauricio Scheffer
To clarify, you're suggesting a series of DTO objects would perform the job more easily?
Programming Hero
No, no DTOs. Just saying: leave those legacy classes alone and create other classes to work with NHibernate. You'll have full control over these new classes and therefore you can use lazy-loading, etc. I had this similar situation and decided to just start fresh.
Mauricio Scheffer