AutoMapper多个源映射到一个Dto
AutoMapper多个源映射到一个Dto 首先要引入AutoMapper(我电脑用的8.0,9.0版本) 1. 定义源映射对象 Model如下: 实体Social /// <summary> /// 社会属性 /// </summary> public class Social { public int Age { get; set; } public bool IsMarried { get; set; } public string Name { get; set; } } 实体Physical /// <summary> /// 身体属性 /// </summary> public class Physical { public string Eye { get; set; } public string Mouth { get; set; } } PeopleDto public class PeopleDto { public string Eye { get; set; } public string Mouth { get; set; } public string Ear { get; set; } public int Age { get; set; } public bool IsMarried { get; set; } } 2. 映射配置 public