<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
//声明SourceTable
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Default="" Optional="False" Category="Context" Description="源表" %>
2、设置SourceTable
先执行
Tools-Build
然后在属性杂项一栏中设置SourceTable
选择数据库,再选择表。
3、写封装类
namespace Train{
public class Train
{
//这里的内容为私有字段和公开属性。
<%foreach(ColumnSchema column in this.SourceTable.Columns)%>
<%{%>
private <%=column.SystemType%> <%=column.Name%>;
<%}%>
<%foreach(ColumnSchema column in this.SourceTable.Columns)%>
<%{%>
public <%=column.SystemType%> <%=column.Name%>
{
get{return <%=column.Name%>;}
set{<%=column.Name%>=value;}
}
<%}%>
}
}
4、执行Tools-Run 保存
补充:
添加数据库方法
在左边SchemaExplorer中选第二项
ADD添加
Name:Train
ProviderType:sqlSchemaProvider
ConnectionString:server=.;database=Train;uid=sa;pwd="1234"; 这不必要图 如果你还看不懂、、、、
(1)codesmith使用 v2.5
(2)将nhibernatetemplate
整个文件夹放到c:\program files\codesmith\v2.5\samples下。
(3)提供对oracle的支持。用vs2003打开
oraclenativeschemaprovider
项目,项目需要引用schemaexplorer.dll,可在c:\program files\codesmith\v2.5下找到该文件。重新编译后,将编译生成的schemaexplorer.oraclenativeschemaprovider.dll和schemaexplorer.oraclenativeschemaprovider.dll.config文件拷贝c:\program files\codesmith\v2.5下,重新打开codesmith可。
codesmith 4.0的位置就不是这样的了
(4)nhibernate配置示例:<>