AutoMapper自定义拼合

时间:2019-03-27 14:01:22

标签: c# automapper dto

我有这样的结构:

class A {
   public int Id {get;set;}
   public string Code {get;set;}
   public B Data {get;set;}
}

class B {
   public int Id {get;set;}
   public string Name {get;set;}
   public int Price {get;set;}
}

class Dto {
   public int Id {get;set;}
   public string Code {get;set;}
   public string Name {get;set;}
   public int Price {get;set;}
}

我如何教自动映射器使用A.B将所有属性从IdDto除外)映射到Mapper.Map<A,Dto>(a)?如果Dto属性类似于DataNameDataPrice,它应该可以工作,但是我不想重命名所有属性。

0 个答案:

没有答案