HyperDAL 代码生成器 HyperDTT 一个模板示例

这段博客内容是一段C#代码,用于生成业务对象类。代码中定义了命名空间、类,通过循环处理表的列映射,为每列生成对应的私有字段和公共属性,实现数据的封装和访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

以下是 HyperDAL 代码生成器模板中的一个模板示例。

在这个示例中,展现了 HyperDTT 是如何将 Smartsoft.HyperDAL.dll 程序集的 tableMap 对象注入到模板中和模板是如何操作注入的 tableMap 对象来完成模板翻译工作的。

<%@ template kind='script' %>
<%@ template language="cs" %>
<%@ template references="Smartsoft.HyperDAL.dll" %>
<%@ template imports="Smartsoft.HyperDAL" %>
<%
  string appNamespace = DTTDomain[ "APP_NAMESPACE" ] as string;
  TableMap tableMap = DTTInput[ "TABLE_MAP" ] as TableMap;
 
  int index = 0;
  int count = tableMap.ColumnMaps.Count;
%>
using System;

namespace <%=appNamespace%>
{
  /// <summary>
  /// Summary description for <%=tableMap.TokenName%>BusinessObject.
  /// </summary>
  public class <%=tableMap.TokenName%>BusinessObject
  {
    public <%=tableMap.TokenName%>BusinessObject()
    {
    }

<%
  for( index = 0; index < count; index++ )
  {
    ColumnMap cm = tableMap.ColumnMaps[ index ];
   
    string start = new string( cm.Caption[ 0 ], 1 );
   
    string fieldName = start.ToLower() + cm.Caption.Substring( 1 );
    string attrName = start.ToUpper() + cm.Caption.Substring( 1 );
%>
    private <%=cm.DataType%> _<%=fieldName%>;

    public <%=cm.DataType%> <%=attrName%>
    {
      get{ return( _<%=fieldName%> ); }
      set{ _<%=fieldName%> = value; }
    }
<%
    if( index < count - 1 )
    {
%>
   
<%
    }
  }
%>
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值