<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="System.Data" %>
<%@ Property Name="NameSpace" Type="String" Default="" Optional="False" Category="info" Description="Enter Your Name" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Property Name="DataSource" Type="SchemaExplorer.TableSchema" Default="" Optional="False" Category="" Description="" OnChanged="" Editor="" EditorBase="" Serializer="" %>
using System;
using System.Collections.Generic;
using System.Text;
namespace <%=NameSpace%>
{
public class <%=GetTableName(DataSource.Name)%>
{
<% for(int i = 0;i<DataSource.Columns.Count;i++) {%>
private <%=GetCSharpVariableType(DataSource.Columns[i])%> <%=ToCamel(DataSource.Columns[i].Name)%>;
public <%=GetCSharpVariableType(DataSource.Columns[i])%> <%=ToPascal(DataSource.Columns[i].Name)%>
{
get{return <%=ToCamel(DataSource.Columns[i].Name)%>}
set{<%=ToCamel(DataSource.Columns[i].Name)%> = value}
}
<%if(DataSource.Columns[i].IsForeignKeyMember){%>
private <%=GetCSharpVariableType(DataSource.Columns[i])%> <%=GetForginKeyName(ToCamel(DataSource.Columns[i].Name))%>;
public <%=GetCSharpVariableType(DataSource.Columns[i])%> <%=GetForginKeyName(ToPascal(DataSource.Columns[i].Name))%>
{
get{return <%=GetForginKeyName(ToCamel(DataSource.Columns[i].Name))%>}
set{<%=GetForginKeyName(ToCamel(DataSource.Columns[i].Name))%> = value}
}
<%}}%>
}
}
<%--
<%for(int i = 0;i<=100;i++){%>
DataSource:<%=i+" "+DataSource.Name%>
<%}%> --%>
<script runat="template">
//转换为小写
public string ToLower(string str)
{
return str.ToLower();
}
public override string GetFileName()
{
return ToPascal(DataSource.Name) + ".cs";
}
public string ToCamel(string str)
{
return str[0].ToString().ToLower()+str.Substring(1);
}
public string ToPascal(string str)
{
return str[0].ToString().ToUpper()+str.Substring(1);
}
//获得类名,,去掉去掉最后的“S”
public string GetTableName(String tableName)
{
if(tableName.ToLower().EndsWith("s"))
{
tableName = tableName.Substring(0,tableName.Length-1);
}
return tableName;
}
public string GetCSharpVariableType(ColumnSchema column)
{
if (column.Name.EndsWith("TypeCode")) return column.Name;
switch (column.DataType)
{
case DbType.AnsiString: return "string";
case DbType.AnsiStringFixedLength: return "string";
case DbType.Binary: return "byte[]";
case DbType.Boolean: return "bool";
case DbType.Byte: return "byte";
case DbType.Currency: return "decimal";
case DbType.Date: return "DateTime";
case DbType.DateTime: return "DateTime";
case DbType.Decimal: return "decimal";
case DbType.Double: return "double";
case DbType.Guid: return "Guid";
case DbType.Int16: return "short";
case DbType.Int32: return "int";
case DbType.Int64: return "long";
case DbType.Object: return "object";
case DbType.SByte: return "sbyte";
case DbType.Single: return "float";
case DbType.String: return "string";
case DbType.StringFixedLength: return "string";
case DbType.Time: return "TimeSpan";
case DbType.UInt16: return "ushort";
case DbType.UInt32: return "uint";
case DbType.UInt64: return "ulong";
case DbType.VarNumeric: return "decimal";
default:
{
return "__UNKNOWN__" + column.NativeType;
}
}
}
public string GetForginKeyName(string columnName)
{
return columnName.Substring(0,columnName.Length-2);
}
</script>
没有合适的资源?快使用搜索试试~ 我知道了~
CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载
共3个文件
txt:1个
msi:1个
exe:1个
4星 · 超过85%的资源 需积分: 9 158 下载量 145 浏览量
2009-11-19
16:56:31
上传
评论 4
收藏 12.48MB RAR 举报
温馨提示
CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载CodeSmith 下载
资源推荐
资源详情
资源评论
收起资源包目录
CodeSmith.rar (3个子文件)
CodeSmith
123.txt 4KB
CodeSmith.Pro.4.1.2
CodeSmithProfessional-41.msi 13.2MB
CRACK
Keygen.exe 135KB
共 3 条
- 1
资源评论
- qq18501757362012-09-19功能很强大, 但要花点时间学习。 要一劳永逸。
- oLanSeShanHu12013-02-05功能挺强大的,又是一款实用的软件,值得分享!
- livingandlearning2012-07-07模板实用性不强
- Jamson_lin2013-03-04还不错,模板简单实用
hutaocun
- 粉丝: 1
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功