您的位置:首页 > 其它

DbEntry.Net3.6 Model from a database table CodeSimth 模板

2009-12-05 14:19 441 查看
<%--
Name: DbEntry.Net3.6
Author: shiningrise@gmail.com
Description: Create DbEntry.Net3.6 Model from a database table
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Description="Create a list of properties from database table." %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lephone.Data.Definition;
using Lephone.Linq;

namespace Wz16.Models //Chang it to you namespace string
{
/// <summary>
/// <%= this.SourceTable.Description %>
/// </summary>
[DbTable("<%= this.SourceTable.Name %>")]
public abstract class <%= StringUtil.ToPascalCase(this.SourceTable.Name) %> : LinqObjectModel< <%= StringUtil.ToPascalCase(this.SourceTable.Name) %>>
{
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
<% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
/// <summary>
/// <%= column.Description %>
/// </summary>
<%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
[Length(<%= column.Size %>)] <% if( column.AllowDBNull ) { %>[AllowNull] <% } %>public abstract <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToPascalCase(column.Name) %> { get; set; }

<% } else { %>
public abstract <%= CSharpAlias[column.SystemType.FullName] %> <% if( column.AllowDBNull ) { %>? <% } %><%= StringUtil.ToPascalCase(column.Name) %> { get; set; }
<% } %>

<% } %>
<% } %>
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: