If you do not need to associate the NodeA implementation with NodeB , add a copy constructor as follows:
class NodeA { public NodeA() { } public NodeA(NodeB node) { Name = node.Name; Children = node.Children.Select(n => new NodeA(n)).ToList(); } public string Name{get;set;} public List<NodeA> Children {get;set;}
If the connection is troubling, you can create a Convert class that does the conversion for you. Note that the Automapper structure generates these types of transforms for you, using reflection over the source and target types.
source share