Automapper with base class and different configuration options for implementations

后端 未结 2 1777
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-12 10:36

I have two classes (MVC view model) which inherits from one abstract base class.

abstract class BaseModel { }

class Car : BaseModel 
{
    public string Speed {         


        
2条回答
  •  自闭症患者
    2021-02-12 10:57

    Here is the topic describing Mapping Inheritance.

    The following should work for you:

    Mapper.CreateMap()
        .Include()
        .Include();//.ForMember(general mapping)
    Mapper.CreateMap();//.ForMember(some specific mapping)
    Mapper.CreateMap();//.ForMember(some specific mapping)
    

提交回复
热议问题