json 列更新需要手动设置
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
41a889f201
commit
5fdbdfec82
|
@ -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 });
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class IRaCISDBContext : DbContext
|
|||
modelBuilder.Entity<Trial>(entity =>
|
||||
{
|
||||
entity.Property(e => e.TrialObjectNameList).HasConversion(v => v == null ? "[]" : JsonConvert.SerializeObject(v),
|
||||
v => string.IsNullOrEmpty(v) ? null : JsonConvert.DeserializeObject<List<TrialObjectNameConfig>>(v));
|
||||
v => string.IsNullOrEmpty(v) ? new List<TrialObjectNameConfig>() : JsonConvert.DeserializeObject<List<TrialObjectNameConfig>>(v));
|
||||
});
|
||||
|
||||
#region pgsql codefirst 配置 暂时屏蔽
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
#endregion
|
||||
|
||||
|
||||
|
||||
void MarkAsModified<TFrom>(TFrom entity, string propertyName);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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>(TFrom entity, string propertyName)
|
||||
{
|
||||
// 获取属性的元数据
|
||||
var entry = _dbContext.Entry(entity);
|
||||
|
||||
// 设置指定属性为已修改
|
||||
entry.Property(propertyName).IsModified = true;
|
||||
}
|
||||
|
||||
|
||||
#region 异步查询
|
||||
|
||||
|
|
Loading…
Reference in New Issue