/Model.cst
Unknown | 125 lines | 110 code | 15 blank | 0 comment | 0 complexity | 95b68b04a13cf3676097f44aeb8f53c0 MD5 | raw file
- <%--
- Name:
- Author: shiningrise@gmail.com
- Description: Generate Model Class for DbEntry.Net 4.2 write in CodeSmith Generator Studio 5.3.2
- --%>
- <%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="Template description here." %>
- <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
- <%@ Property Name="Namespace" Type="System.String" Default="Wxy.Common.Models" Optional="True" Category="Strings" Description="Chang it to you namespace string." %>
- <%@ Property Name="ddl" Type="System.String" Default="DropDownList Fields List" Optional="True" Category="Strings" Description="DropDownList Controls." %>
- <%@ Property Name="rbl" Type="System.String" Default="RadioButtonList Fields List" Optional="True" Category="Strings" Description="RadioButtonList Controls." %>
- <%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
- <%@ Assembly Name="SchemaExplorer" %>
- <%@ Assembly Name="System.Design" %>
- <%@ Import Namespace="SchemaExplorer" %>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Lephone.Data.Definition;
- using Lephone.Linq;
- namespace <%= this.Namespace %>
- {
- /// <summary>
- /// <%= this.SourceTable.Description %>
- /// </summary>
- public class <%= StringUtil.ToPascalCase(this.SourceTable.Name) %> : DbObjectModel<<%= 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<%}%>,Description("<%= column.Description == string.Empty ? StringUtil.ToPascalCase(column.Name) : column.Description %>")]
- public <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToPascalCase(column.Name) %> { get; set; }
- <% } else { %>
- [Description("<%= column.Description == string.Empty ? StringUtil.ToPascalCase(column.Name) : column.Description %>")]
- public <%= CSharpAlias[column.SystemType.FullName] %> <% if( column.AllowDBNull ) { %>? <% } %><%= StringUtil.ToPascalCase(column.Name) %> { get; set; }
- <% } %>
-
- <% } %>
- <% } %>
- }
- }
- #region get data
- <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
- <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
- <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
- tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text = <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> ;// <%= column.Description %>
- <% } else { %>
- tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text = <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> ;// <%= column.Description %>
- <% } %>
- <% } %>
- <% } %>
- #endregion get data
- #region set data
- <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
- <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
- <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
- <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> = tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text;// <%= column.Description %>
- <% } else { %>
- <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> = tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text;// <%= column.Description %>
- <% } %>
- <% } %>
- <% } %>
- #endregion set data
- #region copy data
- <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
- <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
- tag<%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> = src<%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %>;// <%= column.Description %>
- <% } %>
- <% } %>
- #endregion set data
- // <%= this.SourceTable.Name %> ( <%= this.SourceTable.Description %> )
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Lephone.Web;
- using <%= this.Namespace %>;
- namespace <%= this.Namespace %>
- {
- /// <summary>
- /// <%= this.SourceTable.Description %>
- /// </summary>
- public class <%= StringUtil.ToPascalCase(this.SourceTable.Name) %>DataSource : DbEntryDataSource<<%= StringUtil.ToPascalCase(this.SourceTable.Name) %>>
- {
- }
- }
- #region ExtAspNet columun
- <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
- <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
- <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
- <ext:BoundField DataField="<%= StringUtil.ToPascalCase(column.Name) %>" SortField="<%= StringUtil.ToPascalCase(column.Name) %>" Width="100px" HeaderText="<%= column.Description %>" />
- <% } else { %>
- <ext:BoundField DataField="<%= StringUtil.ToPascalCase(column.Name) %>" SortField="<%= StringUtil.ToPascalCase(column.Name) %>" Width="100px" HeaderText="<%= column.Description %>" />
- <% } %>
- <% } %>
- <% } %>
- #endregion
- #region ExtAspNet Edit Form
- <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
- <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
- <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
- <ext:TextBox ID="tbx<%= StringUtil.ToPascalCase(column.Name) %>" runat="server" Label="<%= column.Description %>" Required="<%= column.AllowDBNull==false %>" ShowRedStar="<%= column.AllowDBNull==false %>"> </ext:TextBox>
- <% } else { %>
- <ext:TextBox ID="tbx<%= StringUtil.ToPascalCase(column.Name) %>" runat="server" Label="<%= column.Description %>" Required="<%= column.AllowDBNull==false %>" ShowRedStar="<%= column.AllowDBNull==false %>"> </ext:TextBox>
- <% } %>
- <% } %>
- <% } %>
- #endregion