八、对象映射指南
将一个对象的值批量映射到另一个对象中,支持自定义映射规则。
传统模式(不推荐)
public class Student
{
public string FirstName {get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public string Address { get; set; }
public string Gender {get; set; }
}public class StudentDto
{
public string FullName {get; set; }
public int Age { get; set; }
public string Gender {get; set; }
}对象映射组件(推荐)
Mapster 使用
简单使用
自定义映射规则
特殊映射
数据库实体映射说明
🏴 传统模式(不推荐):
🏴 使用 Mapster 之后(推荐):
将 Dto 映射到已存在的 Entity
Dto 映射到已存在的 Entity最后更新于