修改json 列
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-11-08 17:26:46 +08:00
parent f83bd75853
commit 4145421087
2 changed files with 12 additions and 9 deletions

View File

@ -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();

View File

@ -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<List<TestJsonObject>>(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<List<TestJsonObject>>(v));
});
modelBuilder.Entity<Trial>(entity =>
{
//entity.Property(e => e.TrialObjectNameList).HasConversion(v => v == null ? "[]" : JsonConvert.SerializeObject(v),
// v => string.IsNullOrEmpty(v) ? new List<TrialObjectNameConfig>() : JsonConvert.DeserializeObject<List<TrialObjectNameConfig>>(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; }