zoukankan      html  css  js  c++  java
  • codesmith entity模板for enterprise library 5

    <%@ CodeTemplate Language="C#" TargetLanguage="T-SQL" Debug="true" CompilerVersion="v3.5" Description="" %>
    <%@ Assembly Name="SchemaExplorer" %>
    <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Optional="False" Category="Required" %>
    <%@ Property Name="NameSpace" Optional="False" Type="System.String" Default="Beyondbit.App.Entity" Category="Style" Description="Object Namespace." %>
    //----------------------------------------------------------------
    // Copyright (C) 2012
    //
    // All rights reserved.
    //
    // <%= SourceTable %>.cs
    //
    //
    // create time:<%= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>
    //
    //
    //
    //----------------------------------------------------------------
    using System;
    using System.Data;
    using System.Collections.Generic;
    using System.Text;
    using Beyondbit.Framework.Biz.Entry;
    using Beyondbit.Framework.Sor.Attributes;
    <%--
    SourceTable.Columns[i].ExtendedProperties[]
    ==CS_IsRowGuidCol
    ==CS_IsIdentity
    ==CS_IsComputed
    ==CS_IsDeterministic
    ==CS_IdentitySeed
    ==CS_IdentityIncrement
    ==CS_Default
    ==CS_ComputedDefinition
    ==CS_Collation
    ==CS_ObjectID
    ==CS_SystemType
    ==CS_UserType
    ==MS_Description
    ==CS_Description
    --%>

    namespace <%=NameSpace%> {
    [Serializable]
    public class <%=SourceTable.Name%> {
    <%for (int i = 0; i < SourceTable.Columns.Count; ++i) {%>
    ///
    ///database type:<%=SourceTable.Columns[i].ExtendedProperties["CS_SystemType"].Value%>
    ///
    private <%=GetTypeString(SourceTable.Columns[i])%> _<%=SourceTable.Columns[i].Name%>;

    <%
    bool is_primary = SourceTable.Columns[i].IsPrimaryKeyMember;
    bool is_identity = (SourceTable.Columns[i].ExtendedProperties["CS_IsIdentity"].Value.ToString() == "True");
    %>

    public <%=GetTypeString(SourceTable.Columns[i])%> <%=SourceTable.Columns[i].Name%> {
    get {
    return _<%=SourceTable.Columns[i].Name%>;
    } set {
    _<%=SourceTable.Columns[i].Name%> = value;
    }
    }
    <%}%>
    }
    }

    <script runat="template">
    public string GetTypeString(SchemaExplorer.ColumnSchema clmn) {
    string type = clmn.DataType.ToString();
    switch (type) {
    case "AnsiString":
    case "String":
    type = "String";
    break;
    case "Int32":
    type = "int";
    break;
    case "DateTime":
    type = "DateTime";
    break;
    case "Double":
    type = "double";
    break;
    case "Binary":
    type = "byte[]";
    break;
    case "Boolean":
    type = "bool";
    break;
    case "Decimal":
    type = "decimal";
    break;
    case "Single":
    type = "float";
    break;
    case "Currency":
    type = "decimal";
    break;
    case "Xml":
    type = "string";
    break;
    case "AnsiStringFixedLength":
    type = "string";
    break;
    case "Float":
    type = "float";
    break;
    case "Guid":
    type = "string";
    break;
    case "Byte":
    type = "byte";
    break;

    default:
    //type = "String";
    break;
    }
    return type;
    }

    </script>

  • 相关阅读:
    J2EE技术(一)——JNDI
    软考注定是一次伤痛
    Ultraedit使用技巧收集
    ArcGIS Server Java 自定义Functionality(转)
    用C#动态刷新KML
    ArcGIS Server Java 自定义task
    Python动态刷新kml
    投影坐标知识小结
    tomcat配置数据源通过JNDI访问mysql数据库
    ArcGIS Server Java自定义tool
  • 原文地址:https://www.cnblogs.com/yuanxiaoping_21cn_com/p/3015062.html
Copyright © 2011-2022 走看看