using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OrmTest { public partial class NewUnitTest { public static void Save() { Db.CodeFirst.InitTables(); Db.DbMaintenance.TruncateTable(); Db.Saveable(new UnitSysMenu() { ID="aa", ButtonList="", CreateName="a", CreateTime=DateTime.Now, ImageUrl="", IsDel=true, MenuCode="a", NavigateUrl="a", UpdateName="", Remark="", UpdateTime=DateTime.Now }).ExecuteReturnEntity(); } } public class BaseEntity { /// /// ID /// [SugarColumn(IsPrimaryKey = true, ColumnDescription = "ID", Length = 32)] public string ID { get; set; } /// /// 删除标记 /// [ SugarColumn(ColumnDescription = "删除标记")] public bool IsDel { get; set; } /// /// 排序字段 /// [SugarColumn(ColumnDescription = "排序字段", IsIdentity = true)] public int SortIndex { get; set; } /// /// 添加操作员 /// [ SugarColumn(ColumnDescription = "添加操作员", Length = 10, IsNullable = true)] public string CreateName { get; set; } /// /// 添加时间 /// [ SugarColumn(ColumnDescription = "添加时间", IsNullable = true)] public DateTime? CreateTime { get; set; } /// /// 修改操作员 /// [ SugarColumn(ColumnDescription = "修改操作员", Length = 10, IsNullable = true)] public string UpdateName { get; set; } /// /// 修改时间 /// [ SugarColumn(ColumnDescription = "修改时间", IsNullable = true)] public DateTime? UpdateTime { get; set; } /// /// 备注 /// [SugarColumn(ColumnDescription = "备注", Length = 150, IsNullable = true)] public string Remark { get; set; } } public class UnitSysMenu : BaseEntity { public UnitSysMenu() { } /// /// 菜单图标 /// [SqlSugar.SugarColumn(Length = 150, ColumnDescription = "菜单图标")] public string ImageUrl { get; set; } /// /// 菜单编码 /// [SqlSugar.SugarColumn(Length = 50, ColumnDescription = "菜单编码")] public string MenuCode { get; set; } /// /// 菜单地址 /// [ SqlSugar.SugarColumn(Length = 200, IsNullable = true, ColumnDescription = "菜单地址")] public string NavigateUrl { get; set; } /// /// 菜单功能 /// [SqlSugar.SugarColumn(IsIgnore = true)] public string ButtonList { get; set; } /// /// 排序字段 /// [SugarColumn(ColumnDescription = "排序字段", IsIdentity = true)] public int SortIndex { get; set; } } }