From c3daa75e0e520a4c412ab6e77a53a8c54c51c3c0 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Sat, 14 Sep 2024 13:13:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=98=85=E7=89=87bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Reading/_MapConfig.cs | 5 ++++- .../Service/WorkLoad/_MapConfig.cs | 4 +++- IRaCIS.Core.Application/TestService.cs | 18 ++++++++++++++++-- IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj | 4 ++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 852a75965..8987cd594 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -68,7 +68,10 @@ namespace IRaCIS.Core.Application.Service #endregion CreateMap(); - CreateMap().ForMember(dest => dest.CreateUser, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.CreateUser, opt => opt.Ignore()) + .ForAllMembers(opts => opts.Condition((src, dest, srcMember) => srcMember != null)); + CreateMap(); CreateMap().ForMember(dest => dest.CreateUser, opt => opt.Ignore()); diff --git a/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs b/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs index 4a855e503..a590b98b4 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs @@ -2,6 +2,7 @@ using IRaCIS.Application.Contracts; using IRaCIS.Core.Application.Service.WorkLoad.DTO; using IRaCIS.Core.Domain.Models; +using static IRaCIS.Application.Services.TestService; namespace IRaCIS.Core.Application.Service { @@ -17,7 +18,8 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); - + CreateMap(); + } } diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index d8876bcac..5f37812f2 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -105,18 +105,32 @@ namespace IRaCIS.Application.Services { public Guid TestId { get; set; } - public string TestName { get; set; } + public string? TestName { get; set; } } + public class TestModel2 + { + public Guid TestId { get; set; } + + public string TestName { get; set; } + } + public async Task TestJson() { + var model1 = new TestModel() { TestId = NewId.NextSequentialGuid(), TestName = null }; + var model2 = new TestModel2() { TestId = NewId.NextSequentialGuid(), TestName = "test2" }; + + //_mapper.Map(from, dbEntity); + + var model4= _mapper.Map(model1, model2); + await _trialBodyPartRepository.FirstOrDefaultAsync(); - await _trialBodyPartRepository.Where(t=>t.Trial.Id==Guid.Empty).FirstOrDefaultAsync(); + await _trialBodyPartRepository.Where(t => t.Trial.Id == Guid.Empty).FirstOrDefaultAsync(); return ResponseOutput.Ok(new TestModel(), IRCEmailPasswordHelper.GenerateRandomPassword(10)); } diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index 8f65510a5..555fa1854 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -1,7 +1,7 @@  - + net8.0