I want to use automapper to map between 2 lists. One list contains a code and a string, the other contains the code and other fields. I want to use all the existing values/properties on the destination object, except for one. Is this possible with automapper? I don't want to specify all the properties with a UseDestinationValue(). Tried the following but instead of returning my destination list with the one property updated, it returns a new list with only matching items (in both lists) and all the fields are null:
public static IMappingExpression<TSource, TDest> UseAllDestinationValues<TSource, TDest>(this IMappingExpression<TSource, TDest> expression)
{
expression.ForAllMembers(opt => opt.UseDestinationValue());
return expression;
}
Mapper.CreateMap<Perm, PermViewModel>()
.UseAllDestinationValues()
.ForMember(dest => dest.CanEdit, opt => opt.MapFrom(s => s.editable));
var items = Mapper.Map<List<Perm>, List<PermViewModel>>(list, model.Items.Items);