C# 如何让Automapper选择无参数构造函数

C# 如何让Automapper选择无参数构造函数,c#,automapper,C#,Automapper,我在HuntMemberBLL类中有以下构造函数 // Default Constructor public HuntMemberBLL() {IsNew = true;} // Get Constructor public HuntMemberBLL(long HuntMemberID) { //DbLoading IsNew = false; } 我有一个HuntMemberDTO类,它没有任何构造函数。问题是,当我尝试

我在HuntMemberBLL类中有以下构造函数

// Default Constructor
    public HuntMemberBLL()
    {IsNew = true;}

    // Get Constructor
    public HuntMemberBLL(long HuntMemberID)
    {   //DbLoading
        IsNew = false;
    }

我有一个HuntMemberDTO类,它没有任何构造函数。问题是,当我尝试映射到HuntMemberBLL类时,Automapper选择Get构造函数而不是默认构造函数。有没有办法让它改用默认构造函数

您可以通过ConstructUsing方法指定要使用的构造函数。例如:

Mapper.Initialize(config => 
config.CreateMap<HuntMemberDTO, HuntMemberBLL>()
      .ConstructUsing((Func<HuntMemberDTO, HuntMemberBLL>)(x => new HuntMemberBLL()));
Mapper.Initialize(配置=>
config.CreateMap()
.ConstructUsing((Func)(x=>newhuntmemberbll());

我已经尝试过了,它给了我一个错误,告诉我“以下方法或属性之间的调用不明确:'AutoMapper.IMappingExpression.ConstructUsing(System.Func)'和'AutoMapper.IMappingExpression.ConstructUsing(System.Func)'AutoMapper需要类型信息。你能试试我现在是如何编辑我的代码的吗?