日期:2014-05-18  浏览次数:20457 次

求codesmith template for NHibernate 1.2.0
如题

yuanxhsoft@126.com

------解决方案--------------------
<%@ CodeTemplate Language= "C# " TargetLanguage= "C# " LinePragmas= "True " %>

<%@ Property Name= "SourceTable " Type= "SchemaExplorer.TableSchema "
Category= "SourceTable "
Description= "選擇一個TABLE " %>
<%@ Property Name= "NameSpace " Type= "String "
Category= "Main "
Description= "輸出文件使用的命名空間 " %>
<%@ Property Name= "ClassName " Type= "String "
Category= "Main "
Description= "類名 " %>
<%@ Assembly Name= "SchemaExplorer " %>
<%@ Import Namespace= "SchemaExplorer " %>

//***********************************************************************
// Created: <%= DateTime.Now.ToShortDateString() %>
// File: <%= CodeTemplate.GetFileName() %>
// Description: <%= SourceTable.Name %>
//***********************************************************************



using System;

namespace <%= NameSpace %>
{
/// <summary>
/// <%= SourceTable.Name %> class description here.
/// </summary>
public class <%= ClassName %>
{

<% for (int i=0; i <SourceTable.Columns.Count; i++) %>
<% { %>
<% string colName = SourceTable.Columns[i].Name.ToString(); %>
<% //string colType = SourceTable.Columns[i].SystemType.ToString(); %>
<% ColumnSchema colType = SourceTable.Columns[i]; %>
private <%= GetColumnDataType(colType) %> _ <%= FirstToLower(colName) %> <%= GetDefaultValue(GetColumnDataType(colType)) %> ;
<% } %>


#region Constructor

public <%= SourceTable.Name %> ()
{
//
// TODO: <%= SourceTable.Name %> constructure logic
//
}

public <%= SourceTable.Name %> ( <% for (int i=0; i <SourceTable.Columns.Count; i++) %> <% { %> <% string colName = SourceTable.Columns[i].Name.ToString(); %> <% ColumnSchema colType = SourceTable.Columns[i]; %> <%=GetColumnDataType(colType)%> <%=FirstToLower(colName)%> <% if (i <SourceTable.Columns.Count-1) {%> , <% } %> <% } %> )
{
<% for (int i=0; i <SourceTable.Columns.Count; i++) %>
<% { %>
<% string colName = SourceTable.Columns[i].Name.ToString(); %>
_ <%= FirstToLower(colName) %> = <%= FirstToLower(colName) %> ;
<% } %>
}

#endregion




#region Property
<% for (int i