我有以下结构:
public enum ToDoReminderPreset
{
[Description("Custom"), CustomText("all"), CustomResxText("ToDoPresetCustom", "PdPlanner")]
Custom = 0,
[Description("review my will"), CustomText("will"), CustomResxText("ToDoPresetUploadWill", "PdPlanner")]
UploadWill = 1,
//....
}
public class TodoPreset
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string GroupName { get; set; }
public string LocalizedDescription { get; set; }
}
我想将类映射到枚举。类的ID将是枚举值。
CreateMap<TodoPreset, Data.ToDoReminderPreset>()
.ForMember(dest => dest, opt => opt.MapFrom(src => (Data.ToDoReminderPreset)(int)src.Id));
这是我添加代码时遇到的错误:
成员的自定义配置仅支持顶级 个人成员。
那么,如何将类的整数属性映射到枚举?强文本