1
I’m having trouble ignoring one property that’s like Icollection and another that’s like Generic Class. Type I am ignoring in Profile Map Address class, it works only when Map Personaddresseditviewmodel> Person, when maps Person > Personaddresseditviewmodel does not work.
I am using the version of Automapper 8.0. I have tested the version 6.2.2 and continues the same problem.
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 ();
}
}