@@ -3,6 +3,7 @@ using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using IRaCIS.Core.Infrastructure.Encryption;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
@@ -59,11 +60,13 @@ public class IRaCISDBContext : DbContext
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
modelBuilder.Entity<TestLength>(entity =>
|
||||
{
|
||||
// 使用部分加密值转换器,前 2 个字符不加密,方便模糊搜索
|
||||
entity.Property(e => e.Name)
|
||||
.HasConversion(new PartialEncryptionConverter(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));
|
||||
});
|
||||
|
||||
#region pgsql codefirst 配置 暂时屏蔽
|
||||
@@ -558,7 +561,7 @@ public class IRaCISDBContext : DbContext
|
||||
|
||||
public virtual DbSet<TestLength> TestLength { get; set; }
|
||||
|
||||
public virtual DbSet<EventStoreRecord> EventStoreRecord { get; set; }
|
||||
public virtual DbSet<EventStoreRecord> EventStoreRecord { get; set; }
|
||||
|
||||
|
||||
|
||||
@@ -567,6 +570,32 @@ public class IRaCISDBContext : DbContext
|
||||
public class TestLength : Entity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[StringLength(1000)]
|
||||
public string[] StringList { get; set; }=new string[] { };
|
||||
|
||||
public List<DateTime> DateTimeList { get; set; } = new List<DateTime>();
|
||||
|
||||
[StringLength(1000)]
|
||||
public List<TestEnum> TestEnumList { get; set; } = new List<TestEnum>();
|
||||
|
||||
[MaxLength]
|
||||
public List<TestJsonObject> TestJsonObjectLsit { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public struct TestJsonObject
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
public enum TestEnum
|
||||
{
|
||||
Default = 0,
|
||||
|
||||
First = 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user