I have a need to deep copy an object graph and have the copy routine follow the cascade settings in the class's mapping file. Basically, for every collection and property marked cascade="<anything>", I need to also deep copy that object, preferably resetting the primary key property to the unsaved-value for that type. Here is a simple example of what I'm trying to do:
//load AggRoot #1 var myAggRoot = session.Load(typeof(AggRoot), 1); // assertion: myAggRoot.Id == 1 // assertion: myAggRoot.PropertyWithCascade.Id == 2 // assertion: myAggRoot.PropertyWithNoCascade.Id == 3 var copiedAggRoot = SomeDeepyCopyRoutine(myAggroot); //the properties configured to cascade are deep-copied and their PK's are set to 0. // assertion: copiedAggRoot.Id == 0 // assertion: copiedAggRoot.PropertyWithCascade.Id == 0 //the properties NOT configured to cascade are not deep-copied. // assertion: myAggRoot.PropertyWithNoCascade.Id == 3 Has anyone solved a similar problem? I've googled with no luck. So far I'm copying all aggregate roots by hand, but that is tedious and error-prone. Thanks! -tyler --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
