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

 

<%-- 
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) %> { getset; }
        
        
<% } else { %>
        
public abstract <%= CSharpAlias[column.SystemType.FullName] %> <% if( column.AllowDBNull ) { %>? <% } %><%= StringUtil.ToPascalCase(column.Name) %> { getset; }    
        
<% } %>
        
    
<% } %>
<% } %>
    }
}

 

 

posted @ 2009-12-05 14:19  shiningrise  阅读(524)  评论(0编辑  收藏  举报