对象映射工具

//1.创建映射规则  ,第一个参数为源实体(Model),第二个为目标实体(DTO)  

Mapper.CreateMap<studentSource, studentPurpost>();    

//2.进行转换  ,得到目标实体(DTO)  

var sPurpost = Mapper.Map<studentPurpost>(sSource);    

 

// var info 若上面声明了info
//Mapper.Map(model, info);
// model 映射到 info    info 就已经改变了 返回的也是info 就不用定义变量接收
//执行从源对象到现有目标对象的映射。
//源对象映射
//目标对象映射到

//返回结果
//映射的目标对象,与目标对象相同的实例

相关文章:

  • 2022-01-04
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-12-18
猜你喜欢
  • 2021-12-18
  • 2022-12-23
  • 2021-08-19
  • 2021-10-20
  • 2022-12-23
  • 2021-07-11
  • 2021-12-18
相关资源
相似解决方案