public class StaffFile : FullAuditedAggregateRoot, IMultiTenant //租户 { public Guid? TenantId { get; set; } ///

/// 姓名 /// public string Name { get; set; } /// /// 编号 /// public string Number { get; set; } /// /// 联系电话 /// public string Telephone { get; set; } //public long JobId { get; set; } ///
/// 职位名称
///

public Basic_Job Job { set; get; }//数据库外键(生成带id字段) /// /// 备注 /// public string Remark { get; set; } public long PostId { get; set; } ///
/// 岗位名称
///

public Basic_Post Post { set; get; }//数据库外键(生成带id字段)

} public class SaveStaffFileDto : ExtensibleObject { ///

/// 租户id /// public Guid? TenantId { get; set; } /// /// 主键 /// public int Id { get; set; } /// /// 姓名 /// public string Name { get; set; } /// /// 编号 /// public string Number { get; set; } /// /// 联系电话 /// public string Telephone { get; set; } /// /// 职务 /// public long JobId { get; set; } /// /// 岗位 /// public long PostId { get; set; } /// /// 备注 /// public string Remark { get; set; } } CreateMap<SaveStaffFileDto, StaffFile>().ForMember(dest => dest.Job.Id, opt => opt.MapFrom(src => $"{src.Id}{src.JobId}"));映射对象内容:The line of code CreateMap<SaveStaffFileDto, StaffFile>().ForMember(dest => dest.Job.Id, opt => opt.MapFrom(src => $"{src.Id}{src.JobId}")); is used to map the properties of the SaveStaffFileDto class to the properties of the StaffFile class.

In this case, it is mapping the JobId property of the SaveStaffFileDto class to the Id property of the Job property of the StaffFile class. The mapping is done by concatenating the Id property of the SaveStaffFileDto class with the JobId property of the SaveStaffFileDto class.


原文地址: https://www.cveoy.top/t/topic/pK6l 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录