You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
2.9 KiB
112 lines
2.9 KiB
<%@ 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
|
|
{
|
|
|
|
/// <summary>
|
|
/// <%=tb.CnName%>
|
|
/// </summary>
|
|
public class <%=tb.PropertyName%>Model
|
|
{
|
|
#region <%=tb.PropertyName%>Model
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public <%=tb.PropertyName%>Model()
|
|
{
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public <%=tb.PropertyName%>Model(<%=pkParmList%>)
|
|
{
|
|
<%
|
|
foreach(Field fd in tb.Fields)
|
|
if(fd.IsPK == true)
|
|
Response.WriteLine("\t\t\tthis."+fd.MemberName+" = "+fd.MemberName+";");
|
|
%>
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
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)
|
|
{
|
|
%>
|
|
|
|
/// <summary>
|
|
/// <%=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");
|
|
%> /// </summary>
|
|
public <%=fd.DataType.DotNetType%> <%=fd.MemberName%>{ get; set; }
|
|
|
|
<%
|
|
}
|
|
%><%--Field End--%>
|
|
}
|
|
}
|
|
<%
|
|
CloseResponse();
|
|
}
|
|
%>
|
|
|