AutoMapper 为大写和下划线映射了错误的字段

AutoMapper mapping wrong fields for UPPERCASE & underscope

今天,当我尝试从 TBL_TRAN_IN 映射到 InwardTransactionDto 时,TBL_TRAN_IN 中的字段 Id 被映射到许多字段(以 [=17 结尾) =]) 在 InwardTransactionDto。这是我的代码

public class TBL_TRAN_IN : Entity<string>
{
      [NotMapped]
      public override string Id
      {
           get { return TRX_TYPE + "-" + RELATION_NO + "-" + O_CI_CODE + "-" + R_CI_CODE + "-" + TRX_DATE; }
           set { /* nothing */ }
      }

      public virtual string CHECK_CODE { get; set; }

      public virtual string CREATE_FILE_RESULT_FLAG { get; set; }

      public virtual string FILE_NAME_RESULT { get; set; }
      //and some fields below
}
public class InwardTransactionDto : EntityDto<Guid?>
{
      public string MSG_KEY { get; set; }

      public string R_CI_ID { get; set; }

      public string O_INDIRECT_ID { get; set; }
      public string R_INDIRECT_ID { get; set; }
      //and some fields below
}

我的映射配置

configuration.CreateMap<TBL_TRAN_IN, InwardTransactionDto>().ForMember(x => x.Id, opt => opt.Ignore()).ReverseMap();

映射后,Id的值映射到第二个class中以_ID结尾的所有字段(R_CI_IDO_INDIRECT_IDR_INDIRECT_ID).有人可以帮忙吗?

感谢你的解决方案,Lucian。此问题已通过新名称约定解决:

public class NoNamingConvention : INamingConvention
{
    public static readonly INamingConvention Value = new NoNamingConvention();

    public NoNamingConvention()
    {
    }

    public Regex SplittingExpression { get; } = new Regex(".+");

    public string SeparatorCharacter => "";

    public string ReplaceValue(Match match)
    {
        return match.Value;
    }
}

还有我的初始化程序:

cfg.DestinationMemberNamingConvention = new NoNamingConvention();