I have the following scenario.
public class Foo
{
public virtual string Name { get; set; }
public virtual IList<Bar> Bars { get; set; }
}
public class FooDTO
{
public string Name { get; set; }
public IList<BarDTO> Bars { get; set; }
}
I ignore the collection Bars
CreateMap<Foo,FooDTO>().ForMember(x => x.Bars, opt => opt.Ignore());
Bars is lazy loading and is mapped with BarsDTO. If i only load the Foo entity from Database I only get the Name value. But when the mapping happens I see in SQL Profiler that all Bars are loaded from Database but are not mapped to DTO.
Why Automapper loads the ignored property?
Everything works correctly. In FooDTO is another property which is called BarsCount and Automapper maps count automatically. So I have to delete BarsCount from DTO or also ignore it in mapping.