diff --git a/Blog.Core.Api/Blog.Core.xml b/Blog.Core.Api/Blog.Core.xml
index 6dd7f16..566d345 100644
--- a/Blog.Core.Api/Blog.Core.xml
+++ b/Blog.Core.Api/Blog.Core.xml
@@ -1391,6 +1391,29 @@
+
+
+ 缓存管理
+
+
+
+
+ 测试建表
+
+
+
+
+
+ 测试查询
+
+
+
+
+
+ 测试写入
+
+
+
多租户-多库方案 测试
diff --git a/Blog.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs b/Blog.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs
index e2d5637..29260f0 100644
--- a/Blog.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs
+++ b/Blog.Core.Api/Controllers/Systems/DynamicCodeFirstController.cs
@@ -1,7 +1,11 @@
+using Blog.Core.Common.DB.Extension;
using Blog.Core.Controllers;
using Blog.Core.Model;
+using Blog.Core.Model.Models.RootTkey;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using NetTaste;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SqlSugar;
namespace Blog.Core.Api.Controllers.Systems;
@@ -21,6 +25,36 @@ public class DynamicCodeFirstController : BaseApiController
_db = db;
}
+ ///
+ /// 动态type
+ ///
+ ///
+ private Type GetDynamicType()
+ {
+ return _db.DynamicBuilder().CreateClass("DynamicTestTable")
+ //{table} 占位符会自动替换成表名
+ .CreateIndex(new SugarIndexAttribute("idx_{table}_Code", "Code", OrderByType.Desc))
+ .CreateProperty("Id", typeof(int), new SugarColumn() {IsPrimaryKey = true, IsIdentity = true})
+ .CreateProperty("Code", typeof(string), new SugarColumn() {Length = 50})
+ .CreateProperty("Name", typeof(string), new SugarColumn() {Length = 50})
+ .WithCache()
+ .BuilderType();
+ }
+
+ ///
+ /// 动态type 继承BaseEntity
+ ///
+ ///
+ private Type GetDynamicType2()
+ {
+ return _db.DynamicBuilder().CreateClass("DynamicTestTable2", null, typeof(BaseEntity))
+ //{table} 占位符会自动替换成表名
+ .CreateIndex(new SugarIndexAttribute("idx_{table}_Code", "Code", OrderByType.Desc))
+ .CreateProperty("Code", typeof(string), new SugarColumn() {Length = 50})
+ .CreateProperty("Name", typeof(string), new SugarColumn() {Length = 50})
+ .WithCache()
+ .BuilderType();
+ }
///
/// 测试建表
@@ -29,7 +63,34 @@ public class DynamicCodeFirstController : BaseApiController
[HttpPost]
public MessageModel TestCreateTable()
{
- _db.DynamicBuilder();
+ var type = GetDynamicType();
+ _db.CodeFirst.InitTables(type);
+ return Success();
+ }
+
+ ///
+ /// 测试查询
+ ///
+ ///
+ [HttpGet]
+ public MessageModel