IEnumerable和嵌套集合

我有一个遵循这个XML的嵌套结构,实体对应于外部,中间和内部对象。

<MyXml>
  <OuterObject>
    <OuterObjectID>123</OuterObjectID>
    <OuterObjectName>Out1</OuterObjectName>
    <MiddleObjectList>
      <MiddleObject>
        <MiddleObjectID>456</MiddleObjectID>
        <MiddleObjectName>Middle1</MiddleObjectName>
        <KeyRelatedToChildInnerObjects>InnerObjKey1</KeyRelatedToChildInnerObjects>
        <InnerObjectList>
          <InnerObject>
            <InnerObjectID>789</InnerObjectID>
            <InnerObjectName>Need_to_map_based_in_InnerObjKey1</InnerObjectName>
          </InnerObject>
          <InnerObject>
            <InnerObjectID>654</InnerObjectID>
            <InnerObjectName>This_too_InnerObjects_are_from_different_entity</InnerObjectName>
          </InnerObject>        
        </InnerObjectList>
      </MiddleObject>
    </MiddleObjectList>
  </OuterObject>
  <OuterObject>
    ...
  </OuterObject>
</MyXml>  

我正在尝试使用AutoMapper设置InnerObject集合的值并填充它们。 这些将来自不同的实体/表格,并且将通过它的父级MiddleObject中声明的密钥进行关联。 我有与OuterObject和MiddleObject对应的实体/ DTO,但无法获得映射的InnerObject。 谢谢你的帮助。

链接地址: http://www.djcxy.com/p/37429.html

上一篇: IEnumerable and nested collections

下一篇: AutoMapper objects with different property types