【问题标题】:Is AutoMapper mapping EF relationships well?AutoMapper 映射 EF 关系好吗?
【发布时间】:2009-08-11 14:05:10
【问题描述】:

我正在使用 Entity Framework + AutoMapper 将 EntityObjects 转换为 POCO。

EF 中的关系使用EntityCollection<T>。 POCO 中的关系使用ICollection<T>。自从EntityCollection<T> : ICollection<T>之后,我认为它会非常容易投射。

但是,当 AutoMapper 尝试将 EF EntityCollection<T> 转换为 POCO 时,它会尝试将其转换为 IList,每次看到集合时都会这样做。由于EntityCollection 没有实现IList,所以我拥有的每个关系都没有按预期被AutoMapper 映射,并且在尝试执行强制转换操作时会引发错误。

你们以前见过这个问题吗?

【问题讨论】:

    标签: entity-framework c#-3.0 automapper


    【解决方案1】:

    AutoMapper 仅支持以下类型: * IEnumerable * IEnumerable * ICollection * ICollection * 列表 * 列表 * 列表 * 数组

    看起来像一个错误:http://automapper.codeplex.com/workitem/6342

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多