<#@ template language="c#" HostSpecific="True" #>
<#@ output extension= ".cs" #>
<#
TableHost host = (TableHost)(Host);
host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
#>
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
namespace <#= host.NameSpace #>.Model<# if( host.Folder.Length > 0) {#>.<#= host.Folder #><# } #>
{
<# if( host.TableDescription.Length > 0) {#>
//<#= host.TableDescription #>
<# } #>
public class <#= host.GetModelClass(host.TableName) #>
{
<# foreach (ColumnInfo c in host.Fieldlist)
{ #>/// <summary>
/// <#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #>
/// </summary>
public <#= GetTypeName(c) #> <#= c.ColumnName #> { get;set; }
<# } #>
}
}
<#+
private string GetTypeName(ColumnInfo c)
{
if(c.Nullable && (CodeCommon.DbTypeToCS(c.TypeName).ToString().ToLower())!="string") //如果字段可以为空,并且不是字符串类型 转换为可空类型
{
return CodeCommon.DbTypeToCS(c.TypeName)+"?";
}
else
{
return CodeCommon.DbTypeToCS(c.TypeName);
}
}
#>