views:

89

answers:

2

Hi all,

I am trying to do a deep copy of a NHibernate object (proxy wrapper). I want to do a copy of lazily loaded things also, except the Id of each inner object of the parent object, as it should be generated when I save the new object which is the result of deep copy.

I have tried to use serialization and also tried using AutoMapper (I know, its not meant for this, just gave it a try). Both didn't yield what I want.

I am thinking of manually copying each and every property as the last option, if there is no better way to do it.

I found this question, but it didn't address what I wanted, considering I was reluctant to do the copy manually.

Any suggestions on how to go about it would be really appreciated.

Thanks

A: 

Hi,

we're using Copyable to clone objects (deep clones). Here you can find an article describing Copyable. It provides extension methods (for 'object') that allow to clone object graphs and generally works very well for us. HTH.

andyp
A: 

We had to have more customizations done as we went on cloning the classes.

So, in our case manual clone was the way to go (even though I was hoping for a better solution).

Mahesh Velaga