zoukankan      html  css  js  c++  java
  • CodeSmith如何生成实体类 ,完善版

    <%-- 
    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" %>
    
    [Table("<%=SourceTable.Name%>")]
    public class <%= StringUtil.ToPascalCase(SourceTable.Name.TrimEnd('s')) %>
    {
    
    <% foreach (ColumnSchema column in this.SourceTable.Columns) {  %>
    /// <summary>
    /// <%= column.Description %>
    /// </summary>
    private <%= CSharpAlias[column.SystemType.FullName] %> _<%= StringUtil.ToCamelCase(column.Name) %>;
    [Column("<%=column.Name%>")]
    public <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToPascalCase(column.Name) %>
    {
        get { return _<%= StringUtil.ToCamelCase(column.Name) %>; }
        set { _<%= StringUtil.ToCamelCase(column.Name) %> = value; }
    }
    
    <% } %>
    public <%= StringUtil.ToPascalCase(SourceTable.Name.TrimEnd('s')) %>()
    {
                
    }
    }
  • 相关阅读:
    查看uCOS-II的CPU使用率
    ARM的工作环境和工作模式
    一个简单的 JSON 生成/解析库
    [转] libtool的作用及应用
    Qt 使用 net-snmp 包的过程记录
    Qt 立体水晶按键实现
    xampp 修改 mysql 默认 root 密码
    mint 设置无线 AP
    dpkg 小记
    转-ubuntu清理卸载wine的残余项目
  • 原文地址:https://www.cnblogs.com/dj258/p/6589961.html
Copyright © 2011-2022 走看看