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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值