我有一个对象,需要选择Name属性并将其分配给String。
但是它不工作!
谁来写真正的profile映射
class Tag
{
public string Name {get;set;}
}
public class TagProfile : ProfileBase
{
public TagProfile()
{
CreateMap<Tag, string>()
.ForMember(dest => dest, opt => opt.MapFrom(src => src.Name));
}
}
你可以在profile contractor上试试:
CreateMap<Tag, string>()
.ConvertUsing(source => source.Name);