diff --git a/IRaCIS.Core.Application/Service/MinimalApiService/TestMinimalApiService.cs b/IRaCIS.Core.Application/Service/MinimalApiService/TestMinimalApiService.cs index e8c16d291..25e0511df 100644 --- a/IRaCIS.Core.Application/Service/MinimalApiService/TestMinimalApiService.cs +++ b/IRaCIS.Core.Application/Service/MinimalApiService/TestMinimalApiService.cs @@ -41,6 +41,8 @@ namespace IRaCIS.Core.Application.Service.MinimalApiService //对于json 对象 不能使用count any 操作,但是简单的类型可以的 var jobjectList = _testLengthRepository.AsQueryable().ToList(); + var jobjectList1 = _testLengthRepository.AsQueryable().Where(t=>t.TestJsonObjectLsit.Any(c=>c.Name=="name1")).ToList(); + var d1 = _testLengthRepository.Where(t => t.StringList.Any(t => t == "string1")).ToList(); var d2 = _testLengthRepository.Where(t => t.StringList.Contains("string1")).ToList(); diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 4e8be7336..e5c04e10f 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -66,22 +66,23 @@ public class IRaCISDBContext : DbContext { // 使用部分加密值转换器,前 2 个字符不加密,方便模糊搜索 entity.Property(e => e.Name).HasConversion(new PartialEncryptionConverter(2)); - entity.Property(e => e.TestJsonObjectLsit).HasConversion(v => v == null ? "[]" : JsonConvert.SerializeObject(v), - v => string.IsNullOrEmpty(v) ? null : JsonConvert.DeserializeObject>(v)); + + entity.OwnsMany(x => x.TestJsonObjectLsit, ownedNavigationBuilder => + { + ownedNavigationBuilder.ToJson(); + }); + + //entity.Property(e => e.TestJsonObjectLsit).HasConversion(v => v == null ? "[]" : JsonConvert.SerializeObject(v), + // v => string.IsNullOrEmpty(v) ? null : JsonConvert.DeserializeObject>(v)); }); modelBuilder.Entity(entity => { - //entity.Property(e => e.TrialObjectNameList).HasConversion(v => v == null ? "[]" : JsonConvert.SerializeObject(v), - // v => string.IsNullOrEmpty(v) ? new List() : JsonConvert.DeserializeObject>(v)); + entity.OwnsMany(x => x.TrialObjectNameList, ownedNavigationBuilder => { ownedNavigationBuilder.ToJson(); - - //ownedNavigationBuilder.HasKey(t=>t.Name); - - }); }); @@ -600,7 +601,7 @@ public class TestLength : Entity } -public struct TestJsonObject +public record TestJsonObject { public string Name { get; set; }