0
我需要利特爾幫助將我的viewmodel映射到域模型。AutoMapper配置。 ViewModel到DomainModel
視圖模型:
public class CampaignViewModel
{
public CampaignVM Campaign { get; set; }
public DiscountVM Discount { get; set; }
}
域模型:
public class Campaign : Entity
{
public Campaign();
public Discount Discount { get; set; }
// other properties
}
而且我怎麼可以處理通過automapper? 我試過了:
var config = new MapperConfiguration(cfg => cfg.CreateMap<CampaignViewModel, Campaign>()
.ForMember(dest => dest, opt => opt.MapFrom(src => src.Campaign)));
但是如何映射其他類呢?像DiscountVM =>折扣...