• 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>

  • 相关阅读:
    避免数据脏读
    OGG配置文件中参数化的运用
    GoldenGate基于中间队列文件的初始化
    一次linux中毒,挖矿病毒
    goldengate新版本中查看日志读取点
    dlopen用法参数flag介绍
    gdb调试带参数和调试core
    在现有的git服务器上面创建新的repo
    Play Old Diablo 2 on macOS Catalina
    Odoo中的Environment对象
  • 原文地址:https://www.cnblogs.com/yuanxiaoping_21cn_com/p/3015062.html
Copyright © 2020-2023  润新知