这些是我想要映射的类:
BasicOverview { public IRichTextContent Intro { get; set; } ... } Blogoverviewviewmodel { public IRichTextContent Intro { get; set; } ... }
以下是定义IRichTextContent类型的第三方代码:
// Represents rich text content in a form of structured data public interface IRichTextContent : IEnumerable<IRichTextBlock>,IEnumerable { // // Summary: // List of rich text content blocks IEnumerable<IRichTextBlock> Blocks { get; set; } }
我的Automapper配置文件:
public AutomapperProfile() { CreateMap<BasicOverview,BlogListviewmodel>(); CreateMap<BasicOverview,ReviewListviewmodel>(); CreateMap<BasicOverview,Blogoverviewviewmodel>(); }
这是我得到的错误:
An unhandled exception occurred while processing the request.
InvalidCastException: Unable to cast object of type ‘System.Collections.Generic.List`1[KenticoCloud.Delivery.IRichTextBlock]’ to type ‘KenticoCloud.Delivery.IRichTextContent’.
lambda_method(Closure,BasicOverview,Blogoverviewviewmodel,ResolutionContext )AutoMapperMappingException: Error mapping types.
Mapping types:
BasicOverview -> BlogoverviewviewmodelType Map configuration:
BasicOverview -> BlogoverviewviewmodelDestination Member:
Intro
lambda_method(Closure,ResolutionContext )
CreateMap<IEnumerable<IRichTextBlock>,IRichTextContent>() .ForMember(dest => dest.Blocks,m => m.MapFrom(src => src));
其中产生了以下错误:
TypeLoadException: Method ‘GetEnumerator’ in type ‘Proxy_KenticoCloud.Delivery.IRichTextContent_12345678_’ from assembly ‘AutoMapper.Proxies,Version=0.0.0.0,Culture=neutral,PublicKeyToken=abc123ef45’ does not have an implementation.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。