Your AutoMapper map declaration is correct.
Can you verify that ordersList.orderLines
is not null
or empty before you map it?
It is possible that your OrdersRepository
isn't giving or populating ordersList
the way that you think it is.
IEnumerable<OrderHeader> ordersList = new OrdersRepository().getOrders();
// Check value of ordersList.orderLines.Count here
// (assuming orderLines is an IEnumerable<T>
Update
After verifying that orderLines
is not empty, possible change ProductsDTO
declaration to:
public IEnumerable<ProductsDTO> ProductsDTO { get; set; }
There is not a reason to specify it as List<>
. It is possible you are getting a type mismatch exception, because you aren't able to cast whatever orderLines
is to a List<>
Update 2
You are trying to map IEnumerable<OrderLines>
to IEnumerable<ProductsDTO>
, which aren't congruant types. Do you have a map for this also?
You need something like this as well:
Mapper.CreateMap<OrderLine, ProductsDTO>().forMember(...