Dns 自动映射-如何将一些dto对象映射到一个域对象?

Dns 自动映射-如何将一些dto对象映射到一个域对象?,dns,automapper,dto,Dns,Automapper,Dto,我在使用AutoMapper将一些DTO对象(带有继承的抽象对象)映射到一个域对象时遇到问题 以下是我的物品: 公共类产品 公共抽象类ABaseProductDTO 公共类minimaproductdto:ABaseProductDTO 公共类基本ProductdTo:MinimalProductDTO 公共类MaximalProductDTO:BasicProductDTO 公共类NodeDTO{ABaseProductDTO} 公共类节点{Product} 该节点包含一个产品,因此Nod

我在使用AutoMapper将一些DTO对象(带有继承的抽象对象)映射到一个域对象时遇到问题

以下是我的物品:

  • 公共类产品
  • 公共抽象类ABaseProductDTO
  • 公共类minimaproductdto:ABaseProductDTO
  • 公共类基本ProductdTo:MinimalProductDTO
  • 公共类MaximalProductDTO:BasicProductDTO
  • 公共类NodeDTO{ABaseProductDTO}
  • 公共类节点{Product}
该节点包含一个产品,因此NodeTo包含一个ABaseProductDTO,我想根据枚举将其映射到特定的dto产品

我知道如果每个DTO都有匹配项,我可以使用“包含”,但事实并非如此

所以我的问题是如何将3个dto对象映射到一个域对象中?('minimalcroductdto'、'BasicProductDTO'、'MaximalProductDTO'转化为'Product')


谢谢

我不确定是否有这样的动态映射。您可能需要检查基本对象的枚举,然后为NodeTo调用正确的映射。不优雅,但我愿意工作