我知道这个例外-
缺少类型映射配置或不支持映射。 映射类型: List
1 -> MyType System.Collections.Generic.List1[System.Object,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089] -> MyAssebmly.MyType
其中MyType只是另一个具有必要属性的POCO。我的密码是-
Mapper.CreateMap<AnotherType, MyType>()
.ConvertUsing<CustomTypeResolver>();哪里
internal class CustomTypeResolver : AutoMapper.ITypeConverter<AnotherType,
MyType>
{
//EDIT
public MyType Convert(ResolutionContext context)
{
return new MyType { MyList = new List<T> { new T { ... } } };
}
}
internal class MyType
{
public List<T> MyList { get; set; }
}任何人都知道出了什么问题。
发布于 2015-12-07 08:50:08
您已经定义了从AnotherType到MyType的映射,但考虑到这个异常,您正在尝试将List转换为MyType。我假设您希望从集合中转换每个对象,而不是整个集合(即List对象),因此相应地更新您的代码。
https://stackoverflow.com/questions/34128148
复制相似问题