当前位置:学会吧培训频道电脑知识学习网页制作移动WAP开发利用CodeSmith为SQL Server CE生成项目代码» 正文

利用CodeSmith为SQL Server CE生成项目代码

[08-08 00:48:39]   来源:http://www.xuehuiba.com  移动WAP开发   阅读:8187
概要:TableProperties.cstCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><%-- Name: Database Table PropertiesAuthor: Paul WelterDescription: Create a list of properties from a database table--%><%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Description="Create a list of properties from database table." %><%@ Property Name="SourceTable&q
利用CodeSmith为SQL Server CE生成项目代码,标签:移动WAP开发教程,wap网站开发,http://www.xuehuiba.com
TableProperties.cst
<%-- 
Name: Database Table Properties
Author: Paul Welter
Description: Create a list of properties from a database table
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Description="Create a list of properties from database table." %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %> 

<% foreach (ColumnSchema column in this.SourceTable.Columns) {  %>
private <%= CSharpAlias[column.SystemType.FullName] %> _<%= StringUtil.ToCamelCase(column.Name) %>; 

public <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToPascalCase(column.Name) %>
{
    get { return _<%= StringUtil.ToCamelCase(column.Name) %>; }
    set { _<%= StringUtil.ToCamelCase(column.Name) %> = value; }


<% } %>

模板被打开后,在CodeSmith右边停靠的Properties窗口选择SourceTable属性,点击旁边的“...”按钮浏览并选择一个Northwind.sdf数据库的表。这里我们选择Categories表,并点击Select按钮确定。

现在可以按F5生成代码了,生成的结果如下所示:

生成的代码
private int _categoryID; 

public int CategoryID
{
    get { return _categoryID; }
    set { _categoryID = value; }


private string _categoryName; 

public string CategoryName
{
    get { return _categoryName; }
    set { _categoryName = value; }


private string _description; 

public string Description
{
    get { return _description; }
    set { _description = value; }

上一页  [1] [2] [3]  下一页


Tag:移动WAP开发移动WAP开发教程,wap网站开发电脑知识学习 - 网页制作 - 移动WAP开发
《利用CodeSmith为SQL Server CE生成项目代码》相关文章
Copyright 学会吧 All Right Reserved.
在线学习社区!--学会吧
1 2 3 4 5 6 7 7 8 9 10 11 12 13