Personal I'm having trouble to ignore a property that is like ICollection and another one that is like Generic Class. Type I am ignoring in the Profile Map class Address, it works only when Mapea PersonAddressEditViewModel > Person, when mapping Person > PersonAddressEditViewModel does not work.
I'm using the version of AutoMapper 8.0. I already tested version 6.2.2 and the same problem continues.
public class Person
{
public Person ()
{
Gid = Guid.NewGuid ();
Address = new List <Address> ();
ClientTypePersonDetails = new List <ClientTypePersonDetail> ();
}
[Key]
public Guid Gid {get; set; }
public string Email {get; set; }
public string Name {get; set; }
public DateTime Created_At {get; set; }
public DateTime? Updated_At {get; set; }
public bool IsDeleted {get; set; }
// [NotMapped, IgnoreMap]
public ValidationResult ValidationResult {get; set; }
public virtual ICollection <Address> Address {get; set; }
public class PersonAddressEditViewModel
{
public PersonAddressEditViewModel ()
{
Gid = Guid.NewGuid ();
ClientTypePersonDetails = new List <ClientTypePersonDetailEditViewModel> ();
}
[Display (Name = "ID")]
public Guid Gid {get; set; }
[Display (Name = "Customer type person")]
public string ClientTypeGid {get; set; }
[NotMapped, IgnoreMap]
public ValidationResult ValidationResult {get; set; }
public virtual AddressEditViewModel Address {get; set; }
public class PersonProfile: Profile
{
public PersonProfile ()
{
CreateMap <PersonEditViewModel, Person> (). ReverseMap ();
CreateMap <PersonEditViewModel, Address> (). ReverseMap ();
CreateMap <PersonEditViewModel, PersonAddressEditViewModel> (). ReverseMap ();
CreateMap <PersonAddressEditViewModel, Address> (). ReverseMap ();
CreateMap <PersonAddressEditViewModel, Person> ()
.ForMember (x => x.Address, x => x.Ignore ()). ReverseMap ();
CreateMap <PersonEditViewModel, PersonSearchViewModel> (). ReverseMap ();
CreateMap <PersonEditViewModel, PersonIndexViewModel> (). ReverseMap ();
CreateMap <PersonSearchViewModel, PersonIndexViewModel> (). ReverseMap ();
}
}