41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using AutoMapper;
|
|
using VOL.Entity.DomainModels.XinWei;
|
|
using YD_XinWei.Commons.Dto.Open;
|
|
|
|
namespace YD_XinWei.Api.AutoMappers
|
|
{
|
|
public class MappingProfile : Profile
|
|
{
|
|
public MappingProfile()
|
|
{
|
|
// 建立对象之间的映射规则
|
|
// 如果有需要,您可以定义其他的映射规则
|
|
// CreateMap<SourceClass2, DestinationClass2>();
|
|
// ...
|
|
|
|
//CreateMap<AddHomeWorkDto, S_HomeWork>();
|
|
|
|
CreateMap<XW_Device, DeviceInfoDto>();
|
|
CreateMap<AddTrainDto, XW_SportsTestData>();
|
|
CreateMap<TrainStudentsDto, XW_TrainStudents>();
|
|
CreateMap<TrainSettingDto, XW_TrainSetting>();
|
|
CreateMap<TrainViolationsBODto, XW_TrainViolationsBO>();
|
|
|
|
CreateMap<XW_SportsTestData, TrainDto>();
|
|
CreateMap<XW_SunshineRunTrain, TrainDto>(MemberList.None)
|
|
.ForMember(destination => destination.OrgId, options => options.MapFrom(source => ParseNullableInt(source.OrgId)))
|
|
.ForMember(destination => destination.GradeId, options => options.MapFrom(source => ParseNullableInt(source.GradeId)))
|
|
.ForMember(destination => destination.ClassId, options => options.MapFrom(source => ParseNullableInt(source.ClassId)));
|
|
CreateMap<XW_TrainStudents, TrainStudentsDto>();
|
|
|
|
CreateMap<XW_TrainSetting, TrainSettingDto>();
|
|
CreateMap<XW_TrainViolationsBO, TrainViolationsBODto>();
|
|
}
|
|
|
|
private static int? ParseNullableInt(string? value)
|
|
{
|
|
return int.TryParse(value, out var result) ? result : null;
|
|
}
|
|
}
|
|
}
|