Skip to content

Instantly share code, notes, and snippets.

@bzbetty
Created December 20, 2012 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bzbetty/4343557 to your computer and use it in GitHub Desktop.
Save bzbetty/4343557 to your computer and use it in GitHub Desktop.
foreach (var child in source.ChildCollection)
{
var targetChild = target.ChildCollection.SingleOrDefault(c => c.Equals(child)); //overwrite Equals or replace comparison with an Id comparison
if (targetChild == null)
target.ChildCollection.Add(Mapper.Map<SourceChildType, TargetChildType>(child));
else
Mapper.Map(child, targetChild);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment