%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
<%@ Assembly Src="../Internal/Model.cs" %>
<%@ Assembly Src="../Internal/Extensions.cs" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="SchemaMapper" %>
<%@ Property Name="Table"
Type="SchemaExplorer.TableSchema" %>
<%@ Property Name="EntityNamespace"
Type="System.String" %>
//------------------------------------------------------------------------------
//
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
//
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using OpenAuth.Repository.Core;
namespace <%= EntityNamespace %>
{
///
/// <%= Table.Description %>
///
[Table("<%= Table.Name%>")]
public partial class <%= Table.Name %> : StringEntity
{
public <%= Table.Name %>()
{
<% foreach(ColumnSchema p in Table.Columns) {
if(p.IsPrimaryKeyMember) continue;
string type = p.SystemType.ToNullableType(p.AllowDBNull == true);
if(type =="int" || type=="decimal")
Response.WriteLine(" this."+p.Name+"= 0;");
else if(type =="string")
Response.WriteLine(" this."+p.Name+"= string.Empty;");
else if(type.ToLower().Contains("datetime"))
Response.WriteLine(" this."+p.Name+"= DateTime.Now;");
} // foreach %>
}
<%
foreach(ColumnSchema p in Table.Columns) {
if(p.IsPrimaryKeyMember) continue;
%>
///
/// <%=p.Description %>
///
[Description("<%=p.Description%>")]
<%if(p.Name.LastIndexOf("Id") != -1){%>
[Browsable(false)]
<%}%>
<%if(p.DataType == DbType.Byte){%>
public bool <%= p.Name%> { get; set; }
<%}else{%>
public <%= p.SystemType.ToNullableType(p.AllowDBNull == true) %> <%= p.Name%> { get; set; }
<%}%>
<% } // foreach %>
}
}