字典bug修复

This commit is contained in:
2022-04-15 09:35:31 +08:00
parent 67f41bd139
commit 4cbb37e1b5
4 changed files with 38 additions and 24 deletions
@@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking;
using System.Reflection;
using IRaCIS.Core.Domain.Share;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup;
namespace IRaCIS.Core.Infra.EFCore
@@ -68,11 +69,7 @@ namespace IRaCIS.Core.Infra.EFCore
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//modelBuilder.Entity<TrialSiteSurvey>().HasMany(s => s.TrialSiteUserSurveyList).WithOne(sv => sv.TrialSiteSurvey);
//modelBuilder.Entity<TrialSiteSurvey>().HasMany(s => s.TrialSiteEquipmentSurveyList).WithOne(sv => sv.TrialSiteSurvey);
//modelBuilder.Entity<Dictionary>().Ignore(t => t.MappedValue);
//modelBuilder.Entity<Dictionary>().Property(t => t.MappedValue).HasComputedColumnSql(_userInfo.IsEn_Us? "[Value]":"[ValueCN]");
//modelBuilder.Entity<TrialSiteSurvey>()// .HasQueryFilter(t => t.IsDeleted == false);
if (_userInfo.IsEn_Us)
{
@@ -84,8 +81,9 @@ namespace IRaCIS.Core.Infra.EFCore
}
modelBuilder.Entity<User>().Property(t => t.FullName) .HasComputedColumnSql("[LastName] + ' / ' + [FirstName]",false);
modelBuilder.Entity<User>().Ignore(t => t.FullName);
//modelBuilder.Entity<User>().Property(t => t.FullName) .HasComputedColumnSql("[LastName] + ' / ' + [FirstName]",false);
//modelBuilder.Entity<User>().Ignore(t => t.FullName);
//遍历实体模型手动配置
@@ -1,5 +1,6 @@
using IRaCIS.Core.Domain.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -22,4 +23,15 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
.HasForeignKey(dd => dd.DictionaryId);
}
}
public class DictionaryConfigration : IEntityTypeConfiguration<Dictionary>
{
public void Configure(EntityTypeBuilder<Dictionary> builder)
{
builder.Property(e => e.MappedValue).Metadata.SetBeforeSaveBehavior(PropertySaveBehavior.Ignore);
}
}
}