CodeSmith .NET三层架构模板

Model模板文件:

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a class including a special informational header" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Text" %>
<%@ Property Name="NameSpace" Type="String" Category="Context" Description="The namespace to use for this class" %>
<%@ Property Name="TableName" Type="SchemaExplorer.TableSchema" DeepLoad="True" Optional="False" Category="Context" Description="The name of the table to generate" %>
<%@ Property Name="Author" Type="String" Category="Context"  Description="Author" %>
<%@ Property Name="TablePrefix" Type="System.String" Default="T" Category="Context" Description="The prefix to remove from table names" %>
/*------------------------------------------------
// File Name:<%=ClearPrefix(TableName.Name) %>Info.cs
// File Description:<%=ClearPrefix(TableName.Name) %> DataBase Entity
// Author:<%=Author%>
// Create Time:<%= DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")%>
//------------------------------------------------*/
 
using System;
 
namespace <%=NameSpace%>.Model
{
   /// <summary>
   /// Description <%=TableName.Description %>
   /// </summary>
   [Serializable]
   public class <%=ClearPrefix(TableName.Name) %>Info
   {
          #region Private Protery
          <%for(int i=0;i<TableName.Columns.Count;i++){%>
          private <%=CSharpType(TableName.Columns[i])%> _<%=TableName.Columns[i].Name.Substring(0,1).ToLower()+TableName.Columns[i].Name.Substring(1,TableName.Columns[i].Name.Length-1)%>;
          <%}%>
          #endregion
  
          #region Constructor    
          /// <summary>
          /// <%=ClearPrefix(TableName.Name) %> Constructor
          /// </summary>
        public <%=ClearPrefix(TableName.Name) %>Info()
        {
        }
        
          /// <summary>
          /// <%=ClearPrefix(TableName.Name) %> Constructor With Parameters
          /// </summary>
          <%for(int i=0;i<TableName.Columns.Count;i++){%>
          ///<param name="<%=TableName.Columns[i].Name.Substring(0,1).ToLower()+TableName.Columns[i].Name.Substring(1,TableName.Columns[i].Name.Length-1)%>"><%if(TableName.Columns[i].Description.Length>0){%><%=TableName.Columns[i].Name+"  "+TableName.Columns[i].Description%><%}else{%><%=TableName.Columns[i].Name%><%}%></param>
          <%}%>
          public <%=ClearPrefix(TableName.Name) %>Info(<%for(int i=0;i<TableName.Columns.Count;i++){%><%=CSharpType(TableName.Columns[i])%> <%=TableName.Columns[i].Name.Substring(0,1).ToLower()+TableName.Columns[i].Name.Substring(1,TableName.Columns[i].Name.Length-1)%><% if (i < TableName.Columns.Count - 1) { %>,<%}%><%}%>)
          {
          <%for(int i=0;i<TableName.Columns.Count;i++){%>
           this._<%=TableName.Columns[i].Name.Substring(0,1).ToLower()+TableName.Columns[i].Name.Substring(1,TableName.Columns[i].Name.Length-1)%> = <%=TableName.Columns[i].Name.Substring(0,1).ToLower()+TableName.Columns[i].Name.Substring(1,TableName.Columns[i].Name.Length-1)%>;
          <%}%>
          }
          #endregion
    
          #region Public Property
        <%for(int i=0;i<TableName.Columns.Count;i++){%>
          ///<Summary>
          /// <%=TableName.Columns[i].Name%><%if(TableName.Columns[i].Description.Length>0){%>
          /// <%=TableName.Columns[i].Description%><%}%>
          ///</Summary>
         public <%=CSharpType(TableName.Columns[i]).Trim()%> <%=TableName.Columns[i].Name%>
          {
          get { return _<%=TableName.Columns[i].Name.Substring(0,1).ToLower()+TableName.Columns[i].Name.Substring(1,TableName.Columns[i].Name.Length-1)%>; }
           set {  _<%=TableName.Columns[i].Name.Substring(0,1).ToLower()+TableName.Columns[i].Name.Substring(1,TableName.Columns[i].Name.Length-1)%> = value; }
          }
        <%}%>
          #endregion  
   }
}
<script runat="template">
public string CSharpType(ColumnSchema column)
{
 if (column.Name.EndsWith("TypeCode")) return column.Name;
 switch (column.DataType)
 {
  case DbType.AnsiString:
  case DbType.String:
  case DbType.StringFixedLength:
  case DbType.AnsiStringFixedLength: return "string";
 
  case DbType.VarNumeric:
  case DbType.Currency:
  case DbType.Decimal: return "decimal";
 
  case DbType.Binary: return "byte[]";
  case DbType.Boolean: return "bool";
  case DbType.Byte: return "byte";
  case DbType.Date: return "DateTime";
  case DbType.DateTime: return "DateTime";
  case DbType.Double: return "double";
  case DbType.Guid: return "Guid";
  case DbType.Int16: return "short";
  case DbType.Int32: return "int";
  case DbType.Int64: return "long";
  case DbType.Object: return "object";
  case DbType.SByte: return "sbyte";
  case DbType.Single: return "float";
  case DbType.Time: return "TimeSpan";
  case DbType.UInt16: return "ushort";
  case DbType.UInt32: return "uint";
  case DbType.UInt64: return "ulong";
  default:
  {
   return "__UNKNOWN__" + column.NativeType;
  }
 }
}
public string ClearPrefix(string name)
{
    int mIndex=name.IndexOf(TablePrefix);
    string strResult=name.Remove(0,TablePrefix.Length);
    return strResult;
}
</script>

IDAL模板文件:

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a class including a special informational header" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Text" %>
<%@ Property Name="Namespace" Type="String" Category="Context" Description="The namespace to use for this class" %>
<%@ Property Name="TableName" Type="SchemaExplorer.TableSchema" DeepLoad="True" Optional="False" Category="Context" Description="The name of the table to generate" %>
<%@ Property Name="Author" Type="String" Category="Context"  Description="Author" %>
<%@ Property Name="TablePrefix" Type="System.String" Default="T" Category="Context" Description="The prefix to remove from table names" %>
/*------------------------------------------------
// File Name:I<%=ClearPrefix(TableName.Name) %>.cs
// File Description:<%=ClearPrefix(TableName.Name) %> Interface
// Author:<%=Author%>
// Create Time:<%= DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")%>
//------------------------------------------------*/
 
using System;
using System.Text;
using System.Collections.Generic;
using <%=Namespace%>.Model;
 
namespace <%=Namespace%>.IDAL
{
    /// <summary>
    /// <%=ClearPrefix(TableName.Name) %> Interface
    /// </summary>
    public interface I<%=ClearPrefix(TableName.Name) %>
    {
        /// <summary>
        /// Add <%=ClearPrefix(TableName.Name) %>
        /// </summary>
        /// <param name="model"><%=ClearPrefix(TableName.Name) %> Model</param>
        /// <returns>True or False</returns>
        bool Add(<%=ClearPrefix(TableName.Name) %>Info model);
        
        /// <summary>
        /// Delete <%=ClearPrefix(TableName.Name) %> By ID
        /// </summary>
        /// <param name="id"><%=ClearPrefix(TableName.Name) %> ID</param>
        /// <returns>True or False</returns>
        bool DeleteByID(int id);
        
        /// <summary>
        /// Delete <%=ClearPrefix(TableName.Name) %> By Name
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns>True or False</returns>
        bool DeleteByName(string name);
        
        /// <summary>
        /// Update <%=ClearPrefix(TableName.Name) %>
        /// </summary>
        /// <param name="model"><%=ClearPrefix(TableName.Name) %> Model</param>
        /// <returns>True or False</returns>
        bool Update(<%=ClearPrefix(TableName.Name) %>Info model);
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> By ID
        /// </summary>
        /// <param name="id"><%=ClearPrefix(TableName.Name) %> ID</param>
        /// <returns><%=ClearPrefix(TableName.Name) %> Model</returns>
        <%=ClearPrefix(TableName.Name) %>Info Get<%=ClearPrefix(TableName.Name) %>InfoByID(int id);
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> By Name
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns><%=ClearPrefix(TableName.Name) %> Model</returns>
        <%=ClearPrefix(TableName.Name) %>Info Get<%=ClearPrefix(TableName.Name) %>InfoByName(string name);
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> List
        /// </summary>
        /// <returns><%=ClearPrefix(TableName.Name) %> List</returns>
        IList<<%=ClearPrefix(TableName.Name) %>Info> Get<%=ClearPrefix(TableName.Name) %>ListByPage();
        
        /// <summary>
        /// Check If <%=ClearPrefix(TableName.Name) %> Exist
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns>True or False</returns>
        bool Is<%=ClearPrefix(TableName.Name) %>Exist(string name);
    }
}
<script runat="template">
public string ClearPrefix(string name)
{
    int mIndex=name.IndexOf(TablePrefix);
    string strResult=name.Remove(0,TablePrefix.Length);
    return strResult;
}
</script>

SQLServerDAL模板文件:

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a class including a special informational header" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Text" %>
<%@ Property Name="Namespace" Type="String" Category="Context" Description="The namespace to use for this class" %>
<%@ Property Name="TableName" Type="SchemaExplorer.TableSchema" DeepLoad="True" Optional="False" Category="Context" Description="The name of the table to generate" %>
<%@ Property Name="Author" Type="String" Category="Context"  Description="Author" %>
<%@ Property Name="TablePrefix" Type="System.String" Default="T" Category="Context" Description="The prefix to remove from table names" %>
/*------------------------------------------------
// File Name:<%=ClearPrefix(TableName.Name) %>.cs
// File Description:<%=ClearPrefix(TableName.Name) %> SQL Server DataBase Access
// Author:<%=Author%>
// Create Time:<%= DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")%>
//------------------------------------------------*/
 
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using <%=Namespace%>.Model;
using <%=Namespace%>.IDAL;
 
namespace <%=Namespace%>.DAL
{
    /// <summary>
    /// <%=ClearPrefix(TableName.Name) %>
    /// </summary>
    public class <%=ClearPrefix(TableName.Name) %>:I<%=ClearPrefix(TableName.Name) %>
    {
        public <%=ClearPrefix(TableName.Name) %>(){}
        
        #region <%=ClearPrefix(TableName.Name) %> Interface Implement
        /// <summary>
        /// Add <%=ClearPrefix(TableName.Name) %>
        /// </summary>
        /// <param name="model"><%=ClearPrefix(TableName.Name) %> Model</param>
        /// <returns>True or False</returns>
        public bool Add(<%=ClearPrefix(TableName.Name) %>Info model){
            SqlParameter[] param = new SqlParameter[<%=TableName.Columns.Count-1 %>];
            <%for(int i=0;i<TableName.Columns.Count;i++){
            if(((bool)TableName.Columns[i].ExtendedProperties["CS_IsIdentity"].Value) == true) 
            { 
                continue;
            }%>
            param[<%=i %>] = new SqlParameter("@<%=TableName.Columns[i].Name%>",model.<%=TableName.Columns[i].Name%>);
              <%}%>
            
            try
            {
                SQLHelper.ExecuteNonQuery(CommandType.StoredProcedure,"SP_Add<%=ClearPrefix(TableName.Name) %>", param);
                return true;
            }catch
            {
                return false;
            }
        }
        
        /// <summary>
        /// Delete <%=ClearPrefix(TableName.Name) %> By ID
        /// </summary>
        /// <param name="id"><%=ClearPrefix(TableName.Name) %> ID</param>
        /// <returns>True or False</returns>
        public bool DeleteByID(int id){
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@id", id);
            try
            {
                SQLHelper.ExecuteNonQuery(CommandType.StoredProcedure,"SP_Del<%=ClearPrefix(TableName.Name) %>ByID", param);
                return true;
            }catch
            {
                return false;
            }
        }
        
        /// <summary>
        /// Delete <%=ClearPrefix(TableName.Name) %> By Name
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns>True or False</returns>
        public bool DeleteByName(string name){
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@name",name);
            try
            {
                SQLHelper.ExecuteNonQuery(CommandType.StoredProcedure,"SP_Del<%=ClearPrefix(TableName.Name) %>ByName", param);
                return true;
            }catch
            {
                return false;
            }
        }
        
        /// <summary>
        /// Update <%=ClearPrefix(TableName.Name) %>
        /// </summary>
        /// <param name="model"><%=ClearPrefix(TableName.Name) %> Model</param>
        /// <returns>True or False</returns>
        public bool Update(<%=ClearPrefix(TableName.Name) %>Info model){
            SqlParameter[] param = new SqlParameter[<%=TableName.Columns.Count-1 %>];
            <%for(int i=0;i<TableName.Columns.Count;i++){%>
            param[<%=i %>] = new SqlParameter("@<%=TableName.Columns[i].Name%>",model.<%=TableName.Columns[i].Name%>);
              <%}%>
            try
            {
                SQLHelper.ExecuteNonQuery(CommandType.StoredProcedure,"SP_Update<%=ClearPrefix(TableName.Name) %>", param);
                return true;
            }catch
            {
                return false;
            }
        }
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> By ID
        /// </summary>
        /// <param name="id"><%=ClearPrefix(TableName.Name) %> ID</param>
        /// <returns><%=ClearPrefix(TableName.Name) %> Model</returns>
        public <%=ClearPrefix(TableName.Name) %>Info Get<%=ClearPrefix(TableName.Name) %>InfoByID(int id){
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@id", id);
            <%=ClearPrefix(TableName.Name) %>Info model = null;
            using (SqlDataReader dr = SQLHelper.ExecuteReader(CommandType.StoredProcedure,"SP_Get<%=ClearPrefix(TableName.Name) %>ByID", param))
            {
                while (dr.Read())
                {
                    model = Get<%=ClearPrefix(TableName.Name) %>Model(dr);
                }
                return model;
            }
        }
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> By Name
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns><%=ClearPrefix(TableName.Name) %> Model</returns>
        public <%=ClearPrefix(TableName.Name) %>Info Get<%=ClearPrefix(TableName.Name) %>InfoByName(string name){
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@name", name);
            <%=ClearPrefix(TableName.Name) %>Info model = null;
            using (SqlDataReader dr = SQLHelper.ExecuteReader(CommandType.StoredProcedure,"SP_Get<%=ClearPrefix(TableName.Name) %>ByName", param))
            {
                while (dr.Read())
                {
                    model = Get<%=ClearPrefix(TableName.Name) %>Model(dr);
                }
                return model;
            }
        }
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> List
        /// </summary>
        /// <returns><%=ClearPrefix(TableName.Name) %> List</returns>
        public IList<<%=ClearPrefix(TableName.Name) %>Info> Get<%=ClearPrefix(TableName.Name) %>ListByPage(){
            using (SqlDataReader dr = SQLHelper.ExecuteReader(CommandType.StoredProcedure, "SP_Get<%=ClearPrefix(TableName.Name) %>ListByPage", null))
            {
                IList<<%=ClearPrefix(TableName.Name) %>Info> list = new List<<%=ClearPrefix(TableName.Name) %>Info>();
                while(dr.Read())
                {
                    list.Add(Get<%=ClearPrefix(TableName.Name) %>Model(dr));
                }
                return list;
            }
        }
        
        /// <summary>
        /// Check If <%=ClearPrefix(TableName.Name) %> Exist
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns>True or False</returns>
        public bool Is<%=ClearPrefix(TableName.Name) %>Exist(string name){
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@name", name);
            return Convert.ToBoolean(SQLHelper.ExecuteScalar(CommandType.StoredProcedure,"SP_Is<%=ClearPrefix(TableName.Name) %>Exist", param));
        }
        #endregion
        
        #region Private Methods    
        private <%=ClearPrefix(TableName.Name) %>Info Get<%=ClearPrefix(TableName.Name) %>Model(SqlDataReader dr){
            <%=ClearPrefix(TableName.Name) %>Info model=new <%=ClearPrefix(TableName.Name) %>Info();
            <%for(int i=0;i<TableName.Columns.Count;i++){%>
            model.<%=TableName.Columns[i].Name%>=SQLDataHelper.<%=CSharpType(TableName.Columns[i])%>(dr, "<%=TableName.Columns[i].Name%>");
              <%}%>
            return model;
        }
        
        private IList<<%=ClearPrefix(TableName.Name) %>Info> Get<%=ClearPrefix(TableName.Name) %>List(SqlDataReader dr){
            IList<<%=ClearPrefix(TableName.Name) %>Info> list = new List<<%=ClearPrefix(TableName.Name) %>Info>();
            while (dr.Read())
            {
                list.Add(Get<%=ClearPrefix(TableName.Name) %>Model(dr));
            }
            return list;
        }
        #endregion
    }
}
<script runat="template">
public string CSharpType(ColumnSchema column)
{
 if (column.Name.EndsWith("TypeCode")) return column.Name;
 switch (column.DataType)
 {
  case DbType.AnsiString:
  case DbType.String:
  case DbType.StringFixedLength:
  case DbType.AnsiStringFixedLength: return "GetString";
 
  case DbType.Int16:
  case DbType.Int32:
  case DbType.Int64:
  case DbType.UInt16:
  case DbType.UInt32:
  case DbType.UInt64: return "GetInt";
 
  case DbType.Time:
  case DbType.Date:
  case DbType.DateTime: return "GetDateTime";
 
  case DbType.Binary:
  case DbType.SByte:
  case DbType.Byte: return "GetBytes";
 
  case DbType.VarNumeric:
  case DbType.Currency:
  case DbType.Decimal: return "GetDecimal";
 
  case DbType.Single:
  case DbType.Double: return "GetDouble";
 
  case DbType.Boolean: return "GetBoolean";
  case DbType.Guid: return "GetGuid";
  case DbType.Object: return "GetObject";
  default:
  {
   return "__UNKNOWN__" + column.NativeType;
  }
 }
}
public string ClearPrefix(string name)
{
    int mIndex=name.IndexOf(TablePrefix);
    string strResult=name.Remove(0,TablePrefix.Length);
    return strResult;
}
</script>

BLL模板文件:

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a class including a special informational header" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Text" %>
<%@ Property Name="Namespace" Type="String" Category="Context" Description="The namespace to use for this class" %>
<%@ Property Name="TableName" Type="SchemaExplorer.TableSchema" DeepLoad="True" Optional="False" Category="Context" Description="The name of the table to generate" %>
<%@ Property Name="Author" Type="String" Category="Context"  Description="Author" %>
<%@ Property Name="TablePrefix" Type="System.String" Default="T" Category="Context" Description="The prefix to remove from table names" %>
/*------------------------------------------------
// File Name:<%=ClearPrefix(TableName.Name) %>BLL.cs
// File Description:<%=ClearPrefix(TableName.Name) %> Business Logic
// Author:<%=Author%>
// Create Time:<%= DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")%>
//------------------------------------------------*/
 
using System;
using System.Text;
using System.Collections.Generic;
using <%=Namespace%>.Model;
using <%=Namespace%>.IDAL;
 
namespace <%=Namespace%>.BLL
{
    /// <summary>
    /// <%=ClearPrefix(TableName.Name) %>BLL
    /// </summary>
    public class <%=ClearPrefix(TableName.Name) %>BLL
    {
        //Get <%=ClearPrefix(TableName.Name) %> Entity Class from Factory Layer
        private static readonly I<%=ClearPrefix(TableName.Name) %> dal = <%=Namespace%>.DALFactory.DataAccess.<%=ClearPrefix(TableName.Name) %>();
        
        /// <summary>
        /// Add <%=ClearPrefix(TableName.Name) %>
        /// </summary>
        /// <param name="model"><%=ClearPrefix(TableName.Name) %> Model</param>
        /// <returns>True or False</returns>
        public bool Add(<%=ClearPrefix(TableName.Name) %>Info model){
            return dal.Add(model);
        }
        
        /// <summary>
        /// Delete <%=ClearPrefix(TableName.Name) %> By ID
        /// </summary>
        /// <param name="id"><%=ClearPrefix(TableName.Name) %> ID</param>
        /// <returns>True or False</returns>
        public bool DeleteByID(int id){
            return dal.DeleteByID(id);
        }
        
        /// <summary>
        /// Delete <%=ClearPrefix(TableName.Name) %> By Name
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns>True or False</returns>
        public bool DeleteByName(string name){
            return dal.DeleteByName(name);
        }
        
        /// <summary>
        /// Update <%=ClearPrefix(TableName.Name) %>
        /// </summary>
        /// <param name="model"><%=ClearPrefix(TableName.Name) %> Model</param>
        /// <returns>True or False</returns>
        public bool Update(<%=ClearPrefix(TableName.Name) %>Info model){
            return dal.Update(model);
        }
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> By ID
        /// </summary>
        /// <param name="id"><%=ClearPrefix(TableName.Name) %> ID</param>
        /// <returns><%=ClearPrefix(TableName.Name) %> Model</returns>
        public <%=ClearPrefix(TableName.Name) %>Info Get<%=ClearPrefix(TableName.Name) %>InfoByID(int id){
            return dal.Get<%=ClearPrefix(TableName.Name) %>InfoByID(id);
        }
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> By Name
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns><%=ClearPrefix(TableName.Name) %> Model</returns>
        public <%=ClearPrefix(TableName.Name) %>Info Get<%=ClearPrefix(TableName.Name) %>InfoByName(string name){
            return dal.Get<%=ClearPrefix(TableName.Name) %>InfoByName(name);
        }
        
        /// <summary>
        /// Get <%=ClearPrefix(TableName.Name) %> List
        /// </summary>
        /// <returns><%=ClearPrefix(TableName.Name) %> List</returns>
        public IList<<%=ClearPrefix(TableName.Name) %>Info> Get<%=ClearPrefix(TableName.Name) %>ListByPage(){
            return dal.Get<%=ClearPrefix(TableName.Name) %>ListByPage();
        }
        
        /// <summary>
        /// Check If <%=ClearPrefix(TableName.Name) %> Exist
        /// </summary>
        /// <param name="name"><%=ClearPrefix(TableName.Name) %> Name</param>
        /// <returns>True or False</returns>
        public bool Is<%=ClearPrefix(TableName.Name) %>Exist(string name){
            return dal.Is<%=ClearPrefix(TableName.Name) %>Exist(name);
        }
    }
}
<script runat="template">
public string ClearPrefix(string name)
{
    int mIndex=name.IndexOf(TablePrefix);
    string strResult=name.Remove(0,TablePrefix.Length);
    return strResult;
}
</script>

 

CodeSmith .NET三层架构模板

上一篇:c语言输入数据


下一篇:Java经典23种设计模式之行为型模式(二)