@model GenDbTableDto
@{
var className = Model.EntityName;
var classNameRemark = Model.DisplayName;
var ignores = new string[] {
"Id",
"CreationTime",
"CreatorUserId",
"LastModificationTime",
"LastModifierUserId" ,
"DeletionTime",
"DeleterUserId",
"IsDeleted",
"TenantId",
};
var tableInfos = Model.TableInfos
.Where(w => !ignores.Contains(w.ColumnName))
.OrderBy(w => w.Position)
.ToList()
;
}
@functions
{
//获取类型 根据 appTableInfo
string GetType(DbColumnInfo appTableInfo)
{
switch (appTableInfo.DbTypeText)
{
case "uniqueidentifier":
return appTableInfo.IsPrimary ? "Guid" : "Guid?";
case "bit":
case "int":
return appTableInfo.IsPrimary ? "int" : "int?";
case "datetime":
return appTableInfo.IsNullable ? "DateTime?" : "DateTime";
case "float":
case "money":
return appTableInfo.IsNullable ? "double?" : "double";
case "decimal":
return appTableInfo.IsNullable ? "decimal?" : "decimal";
default:
return appTableInfo.IsNullable ? appTableInfo.CsType.Name + "?" : appTableInfo.CsType.Name;
}
}
///
namespace @(Model.Namespace).@(Model.DataBase == "MiaoYuChat" ? "Repository.ChatAI.Admin.Entities.Apps;" : "Repository.EntityFramework.Admin.Entities.Apps;") ////// @(string.IsNullOrWhiteSpace(classNameRemark) ? className : classNameRemark) /// public class @className : @(GetIdType()) { @foreach (var item in tableInfos) {///} }/// @(string.IsNullOrWhiteSpace(item.DisplayName) ? item.ColumnName : item.DisplayName) => 备注: @(string.IsNullOrWhiteSpace(item.Describe) ? item.ColumnName : item.Describe) /// public @(GetTypeNew(item)) @item.ColumnName { get; set; }