CodeSmith如何生成实体类 ,完善版

<%--
Name: Database Table Properties
Author: Paul Welter
Description: Create a list of properties from a database table
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Description="Create a list of properties from database table." %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %> [Table("<%=SourceTable.Name%>")]
public class <%= StringUtil.ToPascalCase(SourceTable.Name.TrimEnd('s')) %>
{ <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
/// <summary>
/// <%= column.Description %>
/// </summary>
private <%= CSharpAlias[column.SystemType.FullName] %> _<%= StringUtil.ToCamelCase(column.Name) %>;
[Column("<%=column.Name%>")]
public <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToPascalCase(column.Name) %>
{
get { return _<%= StringUtil.ToCamelCase(column.Name) %>; }
set { _<%= StringUtil.ToCamelCase(column.Name) %> = value; }
} <% } %>
public <%= StringUtil.ToPascalCase(SourceTable.Name.TrimEnd('s')) %>()
{ }
}
上一篇:Postgresql 二进制字符串函数和操作符


下一篇:java面试题(杨晓峰)---第一讲谈谈你对java平台的理解