更新时间:2022-05-29 23:14:37
这是因为你试图映射到实际的目标类型,而不是目标类型的属性。你可以达到你想要的:
This is because you are trying to map to the actual destination type rather than a property of the destination type. You can achieve what you want with:
Mapper.CreateMap<Tag, string>().ConvertUsing(source => source.Name ?? string.Empty);
尽管这是一个简单得多只是重写的ToString对标签类。
although it would be a lot simpler just to override ToString on the Tag class.