%@ CodeTemplate Language="C#" ClassName="Model" TargetLanguage="C#" Debug="False" Description="" encoding="GB2312" %>
<%@ Property Name="databaseProjectName" Type="System.String" Default="SpSampleDb" Optional="True" Category="Context" Description="" %>
<%@ Property Name="nameSpace" Type="System.String" Default="Model" Optional="True" Category="Context" Description="" %>
<%
DbEntity db = Template.GetDataBase(databaseProjectName);
foreach(Table tb in db.Tables)
{
OpenResponse(databaseProjectName+"\\Model\\"+tb.ModuleName+"\\"+tb.PropertyName+"Model.cs");
string pkParmList = "";
foreach(Field fd in tb.Fields)
{
if(fd.IsPK == true)
pkParmList += fd.DataType.DotNetType+" "+fd.MemberName+",";
}
pkParmList = pkParmList.Trim(',');
%>
using System;
using System.Data;
/*******************************************************/
/*Project:
Module :
Description :
Date : <%=DateTime.Now.ToString()%>
Create : Lxc
Update :
TODO : */
/*******************************************************/
namespace Model
{
///
/// <%=tb.CnName%>
///
public class <%=tb.PropertyName%>Model
{
#region <%=tb.PropertyName%>Model
///
///
///
public <%=tb.PropertyName%>Model()
{
}
///
///
///
public <%=tb.PropertyName%>Model(<%=pkParmList%>)
{
<%
foreach(Field fd in tb.Fields)
if(fd.IsPK == true)
Response.WriteLine("\t\t\tthis."+fd.MemberName+" = "+fd.MemberName+";");
%>
}
///
///
///
public <%=tb.PropertyName%>Model(DataRow dr)
{
<%
foreach(Field fd in tb.Fields)
{
if( fd.DataType.Convert == "ToDateTime")
{
Response.WriteLine("\t\t\tif(dr[\""+fd.MemberName+"\"] != DBNull.Value)");
Response.WriteLine("\t\t\t\tthis."+fd.MemberName +" = Convert."+fd.DataType.Convert+"(dr[\""+fd.MemberName+"\"]);");
}
else if( fd.DataType.Convert == "ToInt32")
{
//Response.WriteLine("\t\t\tint.TryParse(Convert.ToString(dr[\""+fd.MemberName+"\"]),out "+fd.MemberName+");");
Response.WriteLine("\t\t\tthis."+fd.MemberName +" = FormatCom.ToInt(dr[\""+fd.MemberName+"\"]);");
}
else if( fd.DataType.Convert == "ToString")
{
Response.WriteLine("\t\t\tthis."+fd.MemberName +" = Convert."+fd.DataType.Convert+"(dr[\""+fd.MemberName+"\"]);");
}
else
Response.WriteLine("\t\t\tthis."+fd.MemberName +" = FormatCom."+fd.DataType.Convert+"(dr[\""+fd.MemberName+"\"]);");
}
%>
}
#endregion
<%--Field--%>
<%
foreach(Field fd in tb.Fields)
{
%>
///
/// <%=fd.CnName%>
<%
if( fd.Note != "" && fd.Note!= null)
Response.WriteLine("\t\t/// "+fd.Note.Replace("\r\n"," ").Replace("\r"," ").Replace("\n"," "));
if( fd.Identity.Enable == true)
Response.WriteLine("\t\t/// AutoInc");
if( fd.IsPK == true)
Response.WriteLine("\t\t/// PK");
%> ///
public <%=fd.DataType.DotNetType%> <%=fd.MemberName%>{ get; set; }
<%
}
%><%--Field End--%>
}
}
<%
CloseResponse();
}
%>