I have the following situation:
public class Parent : EntityObject
{
EntityCollection<Child> Children { get; set; }
}
public class Child : EntityObject
{
int Id { get; set; }
string Value1 { get; set; }
string Value2 { get; set; }
}
public class ParentViewModel
{
List<ChildViewModel> Children { get; set; }
}
public class ChildViewModel
{
int Id { get; set; }
string Value1 { get; set; }
string Value2 { get; set; }
}
Mapper.CreateMap<ParentViewModel, Parent>();
Mapper.CreateMap<ChildViewModel, Child>();
Is it possible to get AutoMapper to:
- Map objects in the
ParentViewModel.Childrenlist to objects in theParent.ChildrenEntityCollection with matching Ids. - Create new objects in
Parent.Childrenfor objects inParentViewModel.Childrenwhere an object with the id from source is not found in the destination list. - Remove objects from
Parent.Childrenwhere the destination id does not exist in the source list.
Am I going about this all wrong?