I have the following data model
public class Products
{
public string Name { get; set; }
public ICollection<ProductSize> ProductSizes { get; set; }
}
public class ProductSize
{
public double UnitSize { get; set; }
public ICollection<ProductPackage> ProductPackages { get; set; }
}
public class ProductPackage
{
public int ItemsPerPack { get; set; }
public ICollection<ProductPrice> ProductPrices { get; set; }
}
public class ProductPrice
{
public double Price{ get; set; }
}
And I want to map it to the following Dto
public class ProductDto
{
public name Name{ get; set; }
public double UnitSize { get; set; }
public int ItemsPerPack { get; set; }
public double Price{ get; set; }
}
I have read into using AutoMapper for this, but am unsure how to setup the configuration because there would be 4 sources mapping to one destination, all from lists. I would expect to there to be multiple items with the same property values and that is desired. Do I have to ForMember<> map for each item?