diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 43aea96aa..384dc9a7d 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -911,6 +911,7 @@ namespace IRaCIS.Core.Application _mapper.Map(trialConfig, trialInfo); trialInfo.UpdateTime = DateTime.Now; + _trialRepository.MarkAsModified(trialInfo, nameof(trialInfo.TrialObjectNameList)); //await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialConfig.TrialId && t.IsSigned == false, u => new ReadingQuestionCriterionTrial() { CriterionModalitys = trialConfig.Modalitys }); diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 067ef3728..2349455d9 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -72,7 +72,7 @@ public class IRaCISDBContext : DbContext modelBuilder.Entity(entity => { entity.Property(e => e.TrialObjectNameList).HasConversion(v => v == null ? "[]" : JsonConvert.SerializeObject(v), - v => string.IsNullOrEmpty(v) ? null : JsonConvert.DeserializeObject>(v)); + v => string.IsNullOrEmpty(v) ? new List() : JsonConvert.DeserializeObject>(v)); }); #region pgsql codefirst 配置 暂时屏蔽 diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index 20c3f3237..4de2f0c46 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs @@ -73,7 +73,7 @@ namespace IRaCIS.Core.Infra.EFCore #endregion - + void MarkAsModified(TFrom entity, string propertyName); } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 98b87f116..300fe9ef1 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -4,6 +4,7 @@ using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure.Extention; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Query; using Microsoft.Extensions.Localization; @@ -445,6 +446,15 @@ namespace IRaCIS.Core.Infra.EFCore #endregion + public void MarkAsModified(TFrom entity, string propertyName) + { + // 获取属性的元数据 + var entry = _dbContext.Entry(entity); + + // 设置指定属性为已修改 + entry.Property(propertyName).IsModified = true; + } + #region 异步查询