How to use Automapper to construct object without default constructor

前端 未结 2 437
栀梦
栀梦 2020-12-10 02:02

My objects don\'t have a default constructor, they all require a signature of

new Entity(int recordid);

I added the following line:

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 02:54

    Try

    Mapper.CreateMap().ConstructUsing(s => new Entity(s.RecordId));
    

提交回复
热议问题