黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
2010-06-14 14:11
946 查看
在上一篇我们已经用PowerDesigner创建好了需要的测试数据库,下面就可以开始用它完成批量代码生成的工作啦.
下面我会一步步的解释如何用CodeSmith实现预期的结果的,事先声明一下,在此只做一个简单的Demo,并不详细的讲解CodeSmith各个强大的功能,有兴趣的朋友可以打开CodeSmith的帮助文档了解.我只做个抛砖引玉,希望能激起大家更多思想的火花~
先看看CodeSmith的工作原理:
Entity.cst
<%--
作者:黄聪
网址:http://www.cnblogs.com/huangcong
--%>
<%@ CodeTemplate Inherits="CodeTemplate" Language="C#" TargetLanguage="Text" Description="NetTiers main template." Debug="True" ResponseEncoding="UTF-8"%>
<%@ Assembly Name="SchemaExplorer"%>
<%@ Import Namespace="SchemaExplorer"%>
<%@ Property Name="Table" Type="TableSchema" DeepLoad="True" Optional="False" Category="01. Getting Started - Required" Description="Database that the tables views, and stored procedures should be based on. IMPORTANT!!! If SourceTables and SourceViews are left blank, the Entire Database will then be generated."%>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Entity
{
publicpartialclass<%= Table.Name%>
{
<%foreach(ColumnSchema col in Table.Columns){ %>
public<%= col.DataType %><%= col.Name %>{ get;set; }
<% } %>
}
}
哇,期考啦,怎么那么多考试啊~~~~快看书才行了~~~~
下面我会一步步的解释如何用CodeSmith实现预期的结果的,事先声明一下,在此只做一个简单的Demo,并不详细的讲解CodeSmith各个强大的功能,有兴趣的朋友可以打开CodeSmith的帮助文档了解.我只做个抛砖引玉,希望能激起大家更多思想的火花~
先看看CodeSmith的工作原理:
Entity.cst
<%--
作者:黄聪
网址:http://www.cnblogs.com/huangcong
--%>
<%@ CodeTemplate Inherits="CodeTemplate" Language="C#" TargetLanguage="Text" Description="NetTiers main template." Debug="True" ResponseEncoding="UTF-8"%>
<%@ Assembly Name="SchemaExplorer"%>
<%@ Import Namespace="SchemaExplorer"%>
<%@ Property Name="Table" Type="TableSchema" DeepLoad="True" Optional="False" Category="01. Getting Started - Required" Description="Database that the tables views, and stored procedures should be based on. IMPORTANT!!! If SourceTables and SourceViews are left blank, the Entire Database will then be generated."%>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Entity
{
publicpartialclass<%= Table.Name%>
{
<%foreach(ColumnSchema col in Table.Columns){ %>
public<%= col.DataType %><%= col.Name %>{ get;set; }
<% } %>
}
}
哇,期考啦,怎么那么多考试啊~~~~快看书才行了~~~~
相关文章推荐
- 黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
- 黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
- 黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
- 黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
- 黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
- 黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
- 如何使用CodeSmith批量生成代码(原创系列教程)
- 如何使用CodeSmith批量生成代码(原创系列教程)
- [转]黄聪:如何使用CodeSmith批量生成代码
- (转)如何使用CodeSmith批量生成代码
- 如何使用CodeSmith批量生成代码
- 黄聪:CodeSmith和PowerDesigner的使用安装和数据库创建(原创系列教程)
- 如何使用CodeSmith批量生成代码
- 黄聪:CodeSmith和PowerDesigner的使用安装和数据库创建(原创系列教程)
- 如何使用CodeSmith批量生成代码
- 如何使用CodeSmith批量生成代码
- Flexigrid系列使用教程(二)JSON数据生成代码
- 如何使用CodeSmith批量生成代码
- 黄聪:CodeSmith和PowerDesigner的使用安装和数据库创建(原创系列教程)
- 黄聪:CodeSmith和PowerDesigner的使用安装和数据库创建(原创系列教程)