🐛fix: #ICMS86 创建新的任务保存时提示job name不能为null

This commit is contained in:
yubaolee
2025-07-16 21:18:29 +08:00
parent f980fc5afc
commit c85793bb55

View File

@@ -28,7 +28,13 @@ namespace Infrastructure
{
if (obj == null) return default(T);
var config = new MapperConfiguration(cfg=>cfg.CreateMap(obj.GetType(),typeof(T)));
// 当Id为空时不进行映射
var config = new MapperConfiguration(cfg => {
cfg.CreateMap(obj.GetType(), typeof(T))
.ForMember("Id", opt => opt.Condition((src, dest, srcValue) =>
srcValue != null && !string.IsNullOrEmpty(srcValue.ToString())
));
});
var mapper = config.CreateMapper();
return mapper.Map<T>(obj);
}