I'm having an issue from converting a simple class with properties to a class with properties which are also classes themselves called ProductDataField
public class ProductDataField
{
public string Value { get; set; }
public string Name{ get; set; }
}
Source:
public class ProductDetailsViewModel
{
public CultureInfo Language { get; set; }
public string SeoTitle { get; set; }
public string SeoDescription { get; set; }
public string SeoKeywords { get; set; }
public string ProductFamily { get; set; }
}
Dest:
public class DetailsComplexViewModel
{
public ProductDataField Language { get; set; }
public ProductDataField SeoTitle { get; set; }
public ProductDataField SeoDescription { get; set; }
public ProductDataField SeoKeywords { get; set; }
public ProductDataField ProductFamily { get; set; }
}
I am trying to map the "Name" property in ProductDataField to the property name in "ProductDetailsViewModel" and the "Value" property to the value of the property.
I have tried mapping them with CreateMap but im always getting errors like
"Expression 'x => x.ProductFamily.Value' must resolve to top-level member and not any child object's properties"
Any help would be greatly appreciated