1
votes

I am having an issue using AutoMapper to map some DTO objects (abstract object with inheritance) to one domain object.

Here are my objects:

  • public class Product
  • public abstract class ABaseProductDTO
  • public class MinimalProductDTO : ABaseProductDTO
  • public class BasicProductDTO : MinimalProductDTO
  • public class MaximalProductDTO : BasicProductDTO
  • public class NodeDTO { ABaseProductDTO }
  • public class Node { Product }

The Node contains a Product and accordingly the NodeDTO contains an ABaseProductDTO in it which I want to map to a specific dto product according to an enum.

I know that if there's a match for each DTO I can use 'Include' but this is not the case..

So my question is how do I map 3 dto objects into one domain object? ('MinimalProductDTO', 'BasicProductDTO', 'MaximalProductDTO' into 'Product')???

Thanks

1

1 Answers

0
votes

I'm not sure if there is dynamic mappings like that. You might have to check the ENUM of the BASE object and then call the correct mapping for the NodeDTO. Not elegant but I would work.