You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.7 KiB
Plaintext

using FreeSql.DatabaseModel;@{
var gen = Model as RazorModel;
Func<string, string> GetAttributeString = attr => {
if (string.IsNullOrEmpty(attr)) return "";
return string.Concat(", ", attr.Trim('[', ']')).Trim(',');
};
Func<string, string> GetDefaultValue = defval => {
if (string.IsNullOrEmpty(defval)) return "";
return " = " + defval + ";";
};
}@{
switch (gen.fsql.Ado.DataType) {
case FreeSql.DataType.PostgreSQL:
@:using System;
@:using System.Collections;
@:using System.Collections.Generic;
@:using System.Linq;
@:using System.Reflection;
@:using System.Threading.Tasks;
@:using Newtonsoft.Json;
@:using FreeSql.DataAnnotations;
@:using System.Net;
@:using Newtonsoft.Json.Linq;
@:using System.Net.NetworkInformation;
@:using NpgsqlTypes;
@:using Npgsql.LegacyPostgis;
break;
case FreeSql.DataType.SqlServer:
case FreeSql.DataType.MySql:
default:
@:using System;
@:using System.Collections;
@:using System.Collections.Generic;
@:using System.Linq;
@:using System.Reflection;
@:using System.Threading.Tasks;
@:using Newtonsoft.Json;
@:using FreeSql.DataAnnotations;
break;
}
}
namespace @gen.NameSpace {
@if (false == false) {
@:/// <summary>
@:/// @gen.table.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ")
@:/// </summary>
}
[@GetAttributeString(gen.GetTableAttribute())]
public partial class @gen.GetCsName(gen.FullTableName) {
@foreach (var col in gen.columns) {
if (false == false) {
@:/// <summary>
@:/// @col.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ")
@:/// </summary>
}
@:public @gen.GetCsType(col) @gen.GetCsName(col.Name) { get; set; }@GetDefaultValue(gen.GetColumnDefaultValue(col, false))
@:
}
}
@gen.GetMySqlEnumSetDefine()
}