Source Object:
public class Platform_ContentTemplatesModel : OzEfEntity, IEntity<int>
{
public string TemplateContent { get; set; }
public int TemplateIdentifier { get; set; }
public short WebsitePropertyId { get; set; }
public int Id { get; set; }
}
Destination object:
public class OzCpPlatformContentTemplateItemRecord
{
public int Id { get; set; }
public string TemplateContent { get; set; }
public ContentTemplateIdentifierEnum TemplateIdentifier { get; set; }
public WebsitePropertyEnum WebsiteProperty { get; set; }
}
Mapping configuraton:
Mapper.CreateMap<Platform_ContentTemplatesModel, OzCpPlatformContentTemplateItemRecord>()
.ForMember(dest => dest.WebsiteProperty, opt => opt.MapFrom(src => src.WebsitePropertyId));
Now the mapping of TemplateIdentifier from an int to the enum works perfectly. However the mapping of WebsitePropertyid to WebsiteProperty, namely a short to an enum fails with the following exception:
{"Missing type map configuration or unsupported mapping. Mapping types: Int16 -> WebsitePropertyEnum System.Int16 -> WebsitePropertyEnum Destination path: OzCpPlatformContentTemplateItemRecord.WebsiteProperty.WebsiteProperty Source value:1"}
Now I have an enum member with the value of 1. So is the issue here that the underlying type is a short . I cannot change this to an int so how do I work around this?
Make sure that your destination enum maps to a short
public enum WebsitePropertyEnum : short
{
thing1 = 0,
thing2 = 1
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.