CodeSmith生成实体类

<%@ CodeTemplate Language="C#" TargetLanguage="C#" ResponseEncoding="UTF-8" Debug="False" Description="生成数据库实体" %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="属性" Description="要生成实体的数据表" %>
<%@ Property Name="NameSpace" Type="System.String" Optional="False" Default="Modul" Category="属性" Description="实体类所在的命名空间" %>
<%@ Property Name="opuser" Type="System.String" Default="wlitsoft" Optional="False" Category="属性" Description="请输入您的名字" %>
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
/*
*本代码由代码生成器自动生成,请不要更改此文件的任何代码。
*生成时间:<%= DateTime.Now.ToLocalTime() %>
*生成者:<%= opuser %>
*/
using System;
namespace <%= this.NameSpace %>
{
    ///<summary>
    ///<%= this.SourceTable.Name %>的实体类
    ///</summary>
    public class <%= this.SourceTable.Name %>
    {
        <%--生成私有字段.net2.0--%>
        <% foreach (ColumnSchema column in this.SourceTable.Columns) {  %>
        private <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToCamelCase(column.Name) %>;
        <% } %>
    
        <% foreach(ColumnSchema column in this.SourceTable.Columns){%>    
         <%--生成get set 方法--%>
        /// <summary>
        /// <%= column.Description %>
        /// </summary>
        public <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToPascalCase(column.Name) %>
        {
            get { return <%= StringUtil.ToCamelCase(column.Name) %>; }
            set { <%= StringUtil.ToCamelCase(column.Name) %> = value; }
        }
        <%}%>
        
    }
}

 

posted @ 2018-10-12 15:37  兰博丶专属  阅读(816)  评论(1编辑  收藏  举报