生成实体类的codesmith模版

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Description="Creates a simplistic entity object." %>

<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the stored procedures should be based on." %>
<%@ Property Name="NameSpace" Type="System.String" Default="HanBing" Optional="False" Category="" Description="命名空间" %>
<%@ Property Name="Author" Type="System.String" Default="寒冰凝玉" Optional="False" Category="" Description="作者" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace <%=NameSpace%>
{

    [Serializable()]
    public class <%= SourceTable.Name %>Entity
    {

        #region Private Column
        <% for (int i = 0; i < SourceTable.Columns.Count; i++) { %>
        private <%= SourceTable.Columns[i].SystemType %> <%= StringUtil.ToCamelCase(SourceTable.Columns[i].Name) %>;
        <% } %>
        #endregion

        public <%= SourceTable.Name %>Entity()
        {
        }
        public <%= SourceTable.Name %>Entity(<% for (int i = 0; i < SourceTable.Columns.Count-1; i++) { %><%= SourceTable.Columns[i].SystemType %> <%= StringUtil.ToCamelCase(SourceTable.Columns[i].Name) %>,<% } %><% for (int i = SourceTable.Columns.Count-1; i < SourceTable.Columns.Count; i++) { %><%= SourceTable.Columns[i].SystemType %> <%= StringUtil.ToCamelCase(SourceTable.Columns[i].Name) %> <% } %>)
        {
        <% for (int i = 0; i < SourceTable.Columns.Count; i++) { %>
            this.<%= StringUtil.ToCamelCase(SourceTable.Columns[i].Name) %> = <%= StringUtil.ToCamelCase(SourceTable.Columns[i].Name) %>;
        <% } %>
        }
       
        #region public - Property
        <% for (int i = 0; i < SourceTable.Columns.Count; i++) { %>
 
        public <%= SourceTable.Columns[i].SystemType %> <%= StringUtil.ToPascalCase(SourceTable.Columns[i].Name) %>
        {
            get
            {
                return <%= StringUtil.ToCamelCase(SourceTable.Columns[i].Name) %>;
            }
            set
            {
                <%= StringUtil.ToCamelCase(SourceTable.Columns[i].Name) %> = value;
            }
        }
        <% } %>
        #endregion
    }
}

 

 

你可能感兴趣的:(C++,c,UI,Web,Security)