我感谢我正在使用的Drupal

CodeSmith

Asp.net三层架构自动生成代码CodeSmith模版

asp.net模型层,CodeSmith代码自动生成模版

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a very simple business object." %> <%@ Property Name="TargetTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="ModelsNamespace" Default="MyBookShop.Model" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Assembly Name="SchemaExplorer" %> <%@ Assembly Name="System.Data" %> <%@ Import Namespace="SchemaExplorer" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Text.RegularExpressions" %> <% PrintHeader(); %> using System; using System.Collections.Generic; using System.Text;

namespace <%= ModelsNamespace %> { ? ?[Serializable()] ?public class <%= GetModelClassName() %> ?{ ? ??private <%= GetPKPropertyType() %> <%= GetPKMemberVarName() %>; ??<% ?? ??if(TargetTable.ForeignKeys.Count > 0) ??{ ???foreach (TableKeySchema key in TargetTable.ForeignKeys) ???{ ??%> ??private <%= GetFKPropertyType(key) %> <%= GetFKMemberVarName(key) %>; ??<% ???}??? ??} ?? ??foreach (ColumnSchema column in TargetTable.NonKeyColumns) ???{ ???if(GetMemberVariableDefaultValue(column) != "") ???{ ??%> ??private <%= GetPropertyType(column) %> <%= GetMemberVarName(column) %> = <%= GetMemberVariableDefaultValue(column) %>; ??<% ???} ???else ???{ ??%> 节省页面省去后续大量代码......下载CodeSmith代码模板文件dbmadmodels

asp.net三层架构数据访问层,CodeSmith代码自动生成模版

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a very simple business object." %> <%@ Property Name="TargetTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="ModelsNamespace" Default="MyBookShop.Model" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="DALNamespace" Default="MyBookShop.DAL" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="DALClassNameSurfix" Default="DAL" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Assembly Name="SchemaExplorer" %> <%@ Assembly Name="System.Data" %> <%@ Import Namespace="SchemaExplorer" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Text.RegularExpressions" %> <% PrintHeader(); %> using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; using <%= ModelsNamespace %>; namespace <%= DALNamespace %> { ?public class <%= GetDALClassName() %> ?{ ??<%-- public? Book AddBook(Book book) --%> ??????? public? int Add<%= GetModelClassName() %>(<%= GetModelClassName() %> <%= GetModelParamName() %>) ??{ ??????????? string sql = ????<%= GetInsertSQLLine1()%> ????<%= GetInsertSQLLine2()%> ???? ???sql += " ; SELECT @@IDENTITY"; ??????????? try ??????????? { ????SqlParameter[] para = new SqlParameter[] ????{ ?????<% ?????foreach(TableKeySchema key in TargetTable.ForeignKeys) ?????{ ?????%> ?????new SqlParameter("@<%= GetFKForeignIdName(key) %>", <%= GetModelParamName() %>.<%= GetFKPropertyName(key) %>.<%= GetFKPrimaryIdName(key) %>), //FK ?????<% ?????} ?????for(int i=0; i<TargetTable.NonKeyColumns.Count-1; i++) ?????{ ??????ColumnSchema column = TargetTable.NonKeyColumns[i]; ?????%> ?????new SqlParameter("@<%= column.Name %>", <%= GetModelParamName() %>.<%= column.Name %>), ?????<% ?????} ?????for(int i=TargetTable.NonKeyColumns.Count-1; i<TargetTable.NonKeyColumns.Count; i++) ?????{ ??????ColumnSchema lastColumn = TargetTable.NonKeyColumns[i]; ?????%> ?????new SqlParameter("@<%= lastColumn.Name %>", <%= GetModelParamName() %>.<%= lastColumn.Name %>) ?????<% ?????} ?????%> ????}; ???? ??????????????? int row = SqlHelper.ExecuteSql(sql, para); ????return row; ??????????? } ??????????? catch (Exception e) ??????????? { ??????????????? throw e; ??????????? } ??} ?? ??节省页面省去后续大量代码......下载CodeSmith代码模板文件dbmaddal

asp.net三层架构业务层,CodeSmith代码自动生成模版

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a very simple business object." %> <%@ Property Name="TargetTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="ModelsNamespace" Default="MyBookShop.Model" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="DALNamespace" Default="MyBookShop.DAL" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="BLLNamespace" Default="MyOffice.BLL" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="BLLClassNameSurfix" Default="Manager" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Property Name="DALClassNameSurfix" Default="DAL" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %> <%@ Assembly Name="SchemaExplorer" %> <%@ Assembly Name="System.Data" %> <%@ Import Namespace="SchemaExplorer" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Text.RegularExpressions" %> <% PrintHeader(); %> using System; using System.Collections.Generic; using System.Text; using <%= DALNamespace %>; using <%= ModelsNamespace %>; namespace <%= BLLNamespace %> { ??? public class <%= GetBLLClassName() %> ??? { ??private static readonly <%= GetDALClassName() %> dal = new <%= GetDALClassName() %>(); ??????? public? int Add<%= GetModelClassName() %>(<%= GetModelClassName() %> <%= GetModelParamName() %>) ??????? { ???<% ???if(TargetTable.ForeignKeyColumns.Count>0) ???{ ????foreach(TableKeySchema key in TargetTable.ForeignKeys) ????{ ?????if(key.PrimaryKeyTable.ExtendedProperties.Contains("DefaultId")) ?????{ ???%> ??????????? if (<%= GetModelParamName() %>.<%= GetFKPropertyName(key) %> == null) ??????????? { ??????????????? <%= GetModelParamName() %>.<%= GetFKPropertyName(key) %> = new <%= 节省页面省去后续大量代码......下载CodeSmith代码模板文件dbmadbll

CodeSmith程序员必备工具之一,初识篇

今天简单学了下CodeSmith的使用,主要是模版的编写,学会编写模版了,生成代码就是点几下的事了!实体类,数据库访问类,都可以不用再累人了.

CodeSmith下载:

http://search.gougou.com/search?search=codesmith&id=2? 这些资源都不错!

CodeSmith破解:

如果下载的CodeSmith没有带破解,下我提供这个,最新版不知道是多少。