using System.Collections.Generic;
Phone = new HashSet<Phone>();
public People(int id, string name, DateTime? datenasc)
Phone = new HashSet<Phone>();
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual DateTime? DateNasc { get; set; }
public virtual ISet<Phone> Phone { get; set; }
public Phone(int id, string ddd, string number, People people)
public virtual int Id { get; set; }
public virtual string Ddd { get; set; }
public virtual string Number { get; set; }
public virtual People People { get; set; }
Phone = new HashSet<Phone>();
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual DateTime? DateNasc { get; set; }
public virtual ISet<Phone> Phone { get; set; }
public static void Main()
People people = new People();
people.Name = "Exemplo Automapper";
people.DateNasc = DateTime.Parse("01/01/1999");
people.Phone.Add(new Phone()
System.Console.WriteLine("Antes do Automapper");
System.Console.WriteLine(String.Format("{0} - {1} - {2} - Quantidade de Telefones: {3}",
AutoMapper.Mapper.CreateMap(typeof(People), typeof(PeopleView))
.ForMember("Phone", x => x.Ignore());
PeopleView peopleView = AutoMapper.Mapper.Map<PeopleView>(people);
System.Console.WriteLine();
System.Console.WriteLine("Usando o Automapper");
System.Console.WriteLine(String.Format("{0} - {1} - {2} - Quantidade de Telefones: {3}",
peopleView.Phone.Count));
System.Console.WriteLine();
System.Console.WriteLine("\rAutomapper executado com sucesso !!!");