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.Children
list to objects in theParent.Children
EntityCollection with matching Ids. - Create new objects in
Parent.Children
for objects inParentViewModel.Children
where an object with the id from source is not found in the destination list. - Remove objects from
Parent.Children
where the destination id does not exist in the source list.
Am I going about this all wrong?