开发者

How to do deep copy of NHibernate Objects?

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 开发者_Python百科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.


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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜