我有一个从客户端收到的视图模型,看起来像这样
public class OrderViewModel
{
public string Name{get;set;}
public string ContactDetails {get;set;}
public List<FunkyThing_ViewModel> {get;set;}
}
public class FunkyThing_ViewModel
{
public string ThingName{get;set;}
public string Colour{get;set;}
public string Size{get;set;}
}
我希望将其映射到域模型列表,其中每个看起来更像这样:
public class Order
{
public string Name{get;set;}
public string ContactDetails {get;set;}
public string ThingName{get;set;}
public string Colour{get;set;}
public string Size{get;set;}
}
所以我想要最终得到这样的东西:
List<Order> orders = new Orders();
Mapper.CreateMap<OrderViewModel, List<Order>>();
//Something in here to ensure each funky thing creates an additional order....
Mapper.Map(viewModel, orders);