怎么实现无实体建表并能自动分表的功能 返回
怎么实现无实体建表并能自动分表的功能
var typeBilder = db.DynamicBuilder().CreateClass("table1", new SugarTable() { });
//可以循环添加列
typeBilder.CreateProperty("Id", typeof(int), new SugarColumn() { IsPrimaryKey = true, IsIdentity = true });
typeBilder.CreateProperty("decimal", typeof(decimal), new SugarColumn() { Length=5, DecimalDigits=6});
typeBilder.CreateProperty("byte", typeof(float), new SugarColumn() { });
typeBilder.CreateProperty("short", typeof(double), new SugarColumn() { });
typeBilder.CreateProperty("uint", typeof(uint), new SugarColumn() { });
typeBilder.CreateProperty("long", typeof(long), new SugarColumn() {});
typeBilder.CreateProperty("CreateTime", typeof(DateTime), new SugarColumn()
{
没有分表的字段指定
});
typeBilder.WithCache(); //缓存Key 表名+字段名称相加
//创建类
var type = typeBilder.BuilderType();
//创建表
db.CodeFirst.SplitTables().InitTables(type);
无实体没办法写特性进去
热忱回答(2)
-
小杰 VIP0
2026/1/26分表就不能用自增
0 回复 -
𓆡可期✰Str VIP0
2026/1/28@小杰:分表的查询,有自动将字段名转驼峰的方法吗,或者起别名
0 回复