Automapper : mapping issue with inheritance and abstract base class on collections with Entity Framework 4 Proxy Pocos

后端 未结 5 839
轻奢々
轻奢々 2020-12-07 20:23

I am having an issue using AutoMapper (which is an excellent technology) to map a business object to a DTO where I have inheritance off of an abstract base class within a co

5条回答
  •  执念已碎
    2020-12-07 21:16

    I also tried Olivier's example and got the same StackOverflow errors. I also tried subkamran's solution but not luck there as I am not using a base class from the entity model code generation. Automapper still blows up. Until I find a better solution, I just set the Context to not create Proxies when I create a Context object.

    model.Configuration.ProxyCreationEnabled = false; 
    model.Configuration.LazyLoadingEnabled = true; 
    

    I would also like to see an answer to the problem perhaps using something build into Automapper...

    UPDATE: The Pre-release of Automapper corrects this issue and allows for the mapping to cover a DynamicProxy with no extra configuration.

    The release this works in is 2.2.1

提交回复
热议问题