update 种子文件转为XML格式

This commit is contained in:
2021-05-08 14:40:06 +08:00
parent ebd7d303dd
commit f6794e7f41
39 changed files with 5306 additions and 848 deletions

View File

@@ -1,5 +1,8 @@
using Ewide.Core;
using Ewide.Core.Entity;
using Ewide.Core.Extension;
using Ewide.Core.Service;
using Ewide.Core.Util;
using Furion;
using Furion.DatabaseAccessor;
using Furion.FriendlyException;
@@ -7,9 +10,12 @@ using Furion.JsonSerialization;
using Furion.Snowflake;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.Extensions.Caching.Distributed;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Ewide.EntityFramework.Core
@@ -104,7 +110,7 @@ namespace Ewide.EntityFramework.Core
// 当前操作用户信息
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
var userName = App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value;
foreach (var entity in entities)
{
if (entity.Entity.GetType().IsSubclassOf(typeof(DEntityBase)))
@@ -161,5 +167,25 @@ namespace Ewide.EntityFramework.Core
//}
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
XmlSerializerUtil xmlHandler = new XmlSerializerUtil();
Dictionary<Type, object> dic = xmlHandler.ReaderALL();
foreach (KeyValuePair<Type, object> item in dic)
{
List<object> data = new List<object>();
var collection = item.Value as System.Collections.IEnumerable;
if (collection != null)
{
foreach (var obj in collection)
{
data.Add(obj);
}
}
modelBuilder.Entity(item.Key).HasData(data); ;
}
}
}
}