using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using SqlSugar; namespace OrmTest { public class UnitPgSplit { public static void Init() { var db = NewUnitTest.Db; db.Insertable(new SysTest() { CName = "a", Name = "a", Status = OrderStatus.Todo }).SplitTable().ExecuteReturnSnowflakeId(); db.Updateable(new List() { new SysTest() { CName = "b", Name = "b" } }) .UpdateColumns(x => x.Status).SplitTable(it=>it.Take(3)) .ExecuteCommand(); } } } /// /// 测试表1 /// [SplitTable(SplitType.Year)]//按年分表 (自带分表支持 年、季、月、周、日) [SugarTable("sys_test1111_{year}{month}{day}")] public class SysTest { /// /// 主键Id /// [SugarColumn(ColumnDescription = "Id主键", IsPrimaryKey = true)] public virtual long Id { get; set; } /// /// 名称 /// public string Name { get; set; } /// /// 中文名 /// public string CName { get; set; } /// ///状态 /// public OrderStatus Status { get; set; } } /// /// 工单状态 /// [Description("工单状态")] public enum OrderStatus { /// /// 待办 /// [Description("待办")] Todo = 0, /// /// 进行中 /// [Description("进行中")] Doing = 1, /// /// 完成 /// [Description("完成")] Done = 2, /// /// 超时完成 /// [Description("超时完成")] TimeOut = 3, }