PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Model.cst

http://ct4dbentry.codeplex.com
Unknown | 125 lines | 110 code | 15 blank | 0 comment | 0 complexity | 95b68b04a13cf3676097f44aeb8f53c0 MD5 | raw file
  1. <%--
  2. Name:
  3. Author: shiningrise@gmail.com
  4. Description: Generate Model Class for DbEntry.Net 4.2 write in CodeSmith Generator Studio 5.3.2
  5. --%>
  6. <%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="Template description here." %>
  7. <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
  8. <%@ Property Name="Namespace" Type="System.String" Default="Wxy.Common.Models" Optional="True" Category="Strings" Description="Chang it to you namespace string." %>
  9. <%@ Property Name="ddl" Type="System.String" Default="DropDownList Fields List" Optional="True" Category="Strings" Description="DropDownList Controls." %>
  10. <%@ Property Name="rbl" Type="System.String" Default="RadioButtonList Fields List" Optional="True" Category="Strings" Description="RadioButtonList Controls." %>
  11. <%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
  12. <%@ Assembly Name="SchemaExplorer" %>
  13. <%@ Assembly Name="System.Design" %>
  14. <%@ Import Namespace="SchemaExplorer" %>
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using Lephone.Data.Definition;
  20. using Lephone.Linq;
  21. namespace <%= this.Namespace %>
  22. {
  23. /// <summary>
  24. /// <%= this.SourceTable.Description %>
  25. /// </summary>
  26. public class <%= StringUtil.ToPascalCase(this.SourceTable.Name) %> : DbObjectModel<<%= StringUtil.ToPascalCase(this.SourceTable.Name) %>>
  27. {
  28. <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
  29. <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
  30. /// <summary>
  31. /// <%= column.Description %>
  32. /// </summary>
  33. <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
  34. [Length(<%= column.Size %>)<% if( column.AllowDBNull ){ %>,AllowNull<%}%>,Description("<%= column.Description == string.Empty ? StringUtil.ToPascalCase(column.Name) : column.Description %>")]
  35. public <%= CSharpAlias[column.SystemType.FullName] %> <%= StringUtil.ToPascalCase(column.Name) %> { get; set; }
  36. <% } else { %>
  37. [Description("<%= column.Description == string.Empty ? StringUtil.ToPascalCase(column.Name) : column.Description %>")]
  38. public <%= CSharpAlias[column.SystemType.FullName] %> <% if( column.AllowDBNull ) { %>? <% } %><%= StringUtil.ToPascalCase(column.Name) %> { get; set; }
  39. <% } %>
  40. <% } %>
  41. <% } %>
  42. }
  43. }
  44. #region get data
  45. <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
  46. <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
  47. <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
  48. tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text = <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> ;// <%= column.Description %>
  49. <% } else { %>
  50. tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text = <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> ;// <%= column.Description %>
  51. <% } %>
  52. <% } %>
  53. <% } %>
  54. #endregion get data
  55. #region set data
  56. <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
  57. <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
  58. <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
  59. <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> = tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text;// <%= column.Description %>
  60. <% } else { %>
  61. <%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> = tbx<%= StringUtil.ToPascalCase(column.Name) %>.Text;// <%= column.Description %>
  62. <% } %>
  63. <% } %>
  64. <% } %>
  65. #endregion set data
  66. #region copy data
  67. <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
  68. <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
  69. tag<%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %> = src<%= StringUtil.ToCamelCase(this.SourceTable.Name) + "." + StringUtil.ToPascalCase(column.Name) %>;// <%= column.Description %>
  70. <% } %>
  71. <% } %>
  72. #endregion set data
  73. // <%= this.SourceTable.Name %> ( <%= this.SourceTable.Description %> )
  74. using System;
  75. using System.Collections.Generic;
  76. using System.Linq;
  77. using System.Text;
  78. using Lephone.Web;
  79. using <%= this.Namespace %>;
  80. namespace <%= this.Namespace %>
  81. {
  82. /// <summary>
  83. /// <%= this.SourceTable.Description %>
  84. /// </summary>
  85. public class <%= StringUtil.ToPascalCase(this.SourceTable.Name) %>DataSource : DbEntryDataSource<<%= StringUtil.ToPascalCase(this.SourceTable.Name) %>>
  86. {
  87. }
  88. }
  89. #region ExtAspNet columun
  90. <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
  91. <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
  92. <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
  93. <ext:BoundField DataField="<%= StringUtil.ToPascalCase(column.Name) %>" SortField="<%= StringUtil.ToPascalCase(column.Name) %>" Width="100px" HeaderText="<%= column.Description %>" />
  94. <% } else { %>
  95. <ext:BoundField DataField="<%= StringUtil.ToPascalCase(column.Name) %>" SortField="<%= StringUtil.ToPascalCase(column.Name) %>" Width="100px" HeaderText="<%= column.Description %>" />
  96. <% } %>
  97. <% } %>
  98. <% } %>
  99. #endregion
  100. #region ExtAspNet Edit Form
  101. <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
  102. <% if( StringUtil.ToPascalCase(column.Name) != "Id" ) {%>
  103. <%if( CSharpAlias[column.SystemType.FullName] == "string" ) {%>
  104. <ext:TextBox ID="tbx<%= StringUtil.ToPascalCase(column.Name) %>" runat="server" Label="<%= column.Description %>" Required="<%= column.AllowDBNull==false %>" ShowRedStar="<%= column.AllowDBNull==false %>"> </ext:TextBox>
  105. <% } else { %>
  106. <ext:TextBox ID="tbx<%= StringUtil.ToPascalCase(column.Name) %>" runat="server" Label="<%= column.Description %>" Required="<%= column.AllowDBNull==false %>" ShowRedStar="<%= column.AllowDBNull==false %>"> </ext:TextBox>
  107. <% } %>
  108. <% } %>
  109. <% } %>
  110. #endregion