为什么 AutoMapper 不从 NPoco 动态对象映射到实体?
Why is AutoMapper not mapping from NPoco dynamic object to entity?
当我进行 NPoco 获取时
var products = db.Fetch<dynamic>(sql).ToArray();
然后尝试用 AutoMapper 映射它
Mapper.Map<Product[]>(loc)
生成的 Product
没有任何预期值,即使
sql
中列名的名称和大小写,products
中的NPoco.PocoExpando
实例,Product
class,它们都是匹配。
- expando 中的值对于每一列都是正确的。
Product
中的setter是public。
AutoMapper documentation 表明我做的一切都是正确的。这是一个错误还是我遗漏了什么?
在我对 Mapper.Initialize
的调用中,我将 IMapperConfigurationExpression.CreateMissingTypeMaps
设置为 true。这样做似乎干扰了动态映射。
当我进行 NPoco 获取时
var products = db.Fetch<dynamic>(sql).ToArray();
然后尝试用 AutoMapper 映射它
Mapper.Map<Product[]>(loc)
生成的 Product
没有任何预期值,即使
sql
中列名的名称和大小写,products
中的NPoco.PocoExpando
实例,Product
class,它们都是匹配。- expando 中的值对于每一列都是正确的。
Product
中的setter是public。
AutoMapper documentation 表明我做的一切都是正确的。这是一个错误还是我遗漏了什么?
在我对 Mapper.Initialize
的调用中,我将 IMapperConfigurationExpression.CreateMissingTypeMaps
设置为 true。这样做似乎干扰了动态映射。