C# net PDMan/CHINER/元数建模 生成SqlSugar 代码生成器模板
C# net PDMan/CHINER/元数建模 生成SqlSugar 代码生成器模板
C# net PDMan CHINER 元数建模 生成 SqlSugar 代码生成器模板
在版本>=4.0.0版本中 增加分类 代码生成器 >> C# >> Dapper
自带有SqlSugar模板,但是有无法识别null的类型,此模板支持
using System; using System.Collections.Generic; using SqlSugar; $blankline {{ var today=new Date(); var fullYear=today.getFullYear(); var month=today.getMonth() + 1; var days=today.getDate(); var sqlSugartable='[SugarTable("{{=it.entity.defKey}}", TableDescription = "{{=it.func.join(it.entity.defName,it.entity.comment,';')}}")]'; }} /* * @author : xkdong@163.com * @date : {{=fullYear}}-{{=month}}-{{=days}} * @desc : {{=it.func.join(it.entity.defName,it.entity.comment,'-')}} */ namespace Model.DBModel { /// <summary> /// {{=it.func.join(it.entity.defName,it.entity.comment,';')}} /// </summary> {{=sqlSugartable}} public class {{=it.entity.defKey}} { {{~it.entity.fields:field:index}} /// <summary> /// {{=it.func.join(field.defName,field.comment,';')}} /// </summary> {{? field.primaryKey }} [SugarColumn(IsPrimaryKey = true)] {{?}} {{? !field.notNull }} [SugarColumn(IsNullable = true)] {{?}} public {{=field.type}}{{? field.type!='string'&&!field.notNull}}?{{?}} {{=field.defKey}}{ get; set; }$blankline {{~}} } }
生成的效果为:
/// <summary> /// 测试记录 /// </summary> [SugarTable("PlayLog", TableDescription = "测试记录")] public class PlayLog { /// <summary> /// Id /// </summary> [SugarColumn(IsPrimaryKey = true)] public string Id { get; set; } /// <summary> /// 产品编号 /// </summary> [SugarColumn(IsNullable = true)] public string ProductCode { get; set; } /// <summary> /// 测试人员 /// </summary> [SugarColumn(IsNullable = true)] public string UserTest { get; set; } /// <summary> /// 创建时间 /// </summary> [SugarColumn(IsNullable = true)] public DateTime? CreatedTime { get; set; } /// <summary> /// 更新时间 /// </summary> [SugarColumn(IsNullable = true)] public DateTime? UpdatedTime { get; set; } }
ok!
如有问题请联系QQ:
var d=["1","2","3","4","5","6","7","8","9"];
var pass=d[8]+d[6]+d[0]+d[8]+d[2]+d[0]+d[4]+d[3]+d[2];
源代码(github)包(NuGet)关注:ping9719