原地址:http://a13786987835.blog.163.com/blog/static/1060902722010626113858492/
1.安装codesmith4.1 试用期为 30天 因为是英文软件所以配置nettiers 有点困难
2.点击 view>>Template Explorer
在右侧可以看到 有一个 模板浏览窗口已经打开,选择WinformsLibrary 目录下的NetTiers.cst 双击打开
3.点击导航的 View>>properties windows 可以看到属性窗口被打开
4.开始配置 ChooseSourceDatabase 添加数据库链接 我用的是SqlServer数据库 所以链接为server=fanxinjian;database=exam;uid=sa;pwd=sa
名称
| 解释 |
NetTiers | |
模板中的一些属性的解释 | |
01) Get started --required
| |
ChooseSourceDatabase | 选择数据库 |
MappingFile | Mapping文件位置(会根据output目录自动更改,不需要设置) |
OutputDirectory | 文件输出目录 |
RootNameSpace | 根节点的命名空间 |
01b) Filter by Individual Objects - ptional |
|
EnumTables | 枚举表,表中的所有数据都会被用作枚举类型,要求:第一列为主键,第二列为唯一键,第三列为描述,必须添加到SourceTables |
SourceTables | 需要生成的表 |
SourceViews | 需要生成的视图 |
02) FrameworkGeneration - Optional |
|
AutoIncrementBuildVersion | 自动提升版本 |
EntLibVersion | 微软企业库的版本V2或V3 |
ExecuteSql | 生成后自动执行SQL |
IncludeComponentLayer | 生成组建层(service或domain) |
IncludeDatabaseFeatures | 是否包含数据库特性(sql2005特有) |
IncludeGenerateddate | 包含生成的日期(会在生成的文件中包含生成文件时的日期) |
IncludeUnitTest | 保函单元测试(可以选微软的VSTS或NUnit) |
IncludeWCFDataAttributes | 保函WCF属性(需要.net3.0) |
IncludeXmlAttributes | 保函XML属性 |
LaunchVisualStudio | 生成结束后是否运行解决方案 |
SerializeEntityState | 序列时包含化EntityState,在使用WebServices时非常有用 |
SQLFolderName | SQL脚本输出的目录 |
ViewReport | 生成完毕後显示报表 |
03) Namespaces - Required |
|
BusinessLogicLayerNameSpace | 业务逻辑层命名空间(应该是实体层) |
ComponentLayerNameSpace | 组建层命名空间 |
DataAccessLayerNameSpace | 数据访问层的命名空间 |
UnitTestsNameSpace | 单元测试命名空间 |
04) General - Advanced |
|
CompanyName | 公司名称,会被包含在AssemblyInfo.cs中 |
CompanyURL | 公司网址 |
SignAssembly | SNK公钥 |
05) WebLibrary - Advanced |
|
GenerateWebLibrary | 生成web控件 |
IncludeDesignTimeSupport | 包含设计时支持 |
06) Web - Advanced |
|
AttemptCreateLocalVirtualDirectory | 为webservice创建虚拟目录 |
WebServiceOutputPath | webservice的本地路径 |
WebServiceUrl | webservice的URL |
07) Website - Advanced |
|
GenerateWebsite | 创建web站点 |
GenerateWebsiteAdmin | 创建简单的管理员界面 |
IncludeAtlasLibrary | 包含微软的Ajax库 |
IncludeAtlasToolkit | 包含Ajax扩展工具 |
OverwriteWebConfig | 覆盖web.config文件 |
UseWebAppProject | 使用web项目,需要安装AppProject补丁, 中文版不支持 |
WebAdminSiteName | 管理员站点名称 |
08) CRUD - Advanced |
|
CSPUseDefaultValForNonNullableTypes | 自定义存储过程为nullable类型使用默认值 |
CustomProcedureStartsWith | 自定义存储过程的前缀 |
DropStyle | 选择Entity的话生成後Drop删除已经生成的存储过程,选择All的话,会删除满足存储过程前缀,不满足自定义存储过程前缀的存储过程 |
IncludeCustoms | 生成自定义存储过程 |
IncludeDelete | 生成delete存储过程 |
IncludeDrop | 是否生成drop语句,如果是则根据DropStyle生成 |
IncludeFind | 生成Find存储过程 |
IncludeGet | 生成get存储过程 |
IncludeGetList | 生成GetList存储过程 |
IncludeGetLisByFK | 生成根据外键查询的存储过程 |
InclludeGetListByIX | 生成根据唯一键查询的存储过程 |
IncludeInsert | 生成Insert存储过程 |
IncludeManyToMany | 生成多对多关系 |
IncludeRelations | 生成关联 |
IncludeSave | 生成保存 |
IncludeUpade | 生成更新 |
IsolationLevel | 事务隔离级别 |
ParseDbColDefaultVal | 使用数据库字段默认值初始化实体属性 |
RetryEnabled | 允许重试,当执行出错时允许重试 |
RetryMaxAttempts | 重试次数 |
RetrySleepStyle | 重试等待类型 |
RetrySleepTime | 重试间隔时间 |
09) Storedprocedures - Advanced |
|
DeleteSuffix | 存储过程 delete 语句的前缀 |
FindSuffix | 存储过程 find 语句的前缀 |
GrantUser | 存储过程 grant 语句的前缀 |
InsertSuffix | 存储过程 insert 语句的前缀 |
ProcedurePrefix | 存储过程的前缀 |
SelectAllSuffix | 存储过程 select all 语句的前缀 |
SelectSuffix | 存储过程 select 语句的前缀 |
UpdateSuffix | 存储过程 update 语句的前缀 |
10) Code style. - Advanced |
|
AliasFilePath | 别名路径 |
BaseClassFormat | 基类 {0}Base |
ChangeUnderscoreToPascalCase | 将 _ 转换为 Pascal |
CollectionFormat | 子集 {0}Collection 一对多时,会包含子表(数据)的集合 |
EntityFormat | 实体 默认{0} |
EntityKeyFormat | EntityKey {0}Key |
EnumFormat | 枚举 {0}List |
GenericListFormat | Nettiers自带的泛型集合之一 TList<{0}> 表使用 |
GenericViewFormat | 泛型集合之一 VList<{0}> 视图使用 |
InterfaceFormat | 接口 I{0} |
ManyToMayFormat | 多对多 {0}From{1} |
11) MethodNames |
|
BulkInsert | 批量插入方法的名称 |
Deepload | 主从表查询方法的名称 |
DeepSave | 主从表保存方法的名称 |
Delete | 删除方法的名称 |
Find | 查询方法的名称 |
Get | Get方法的名称 |
GetAll | 查询全部方法的名称 |
GetPaged | 分页查询方法的名称 |
GetTotalItems | 查询行数方法的名称 |
Insert | 插入方法的名称 |
Save | 保存方法的名称 |
Update | 更新方法的名称 |
ProviderFormat | {0}Provider |
ServiceClassNameFormat | {0}Service |
StrippedTablePrefixed | 忽略前缀,填写的前缀讲不会被生成到实体中 入tbl;tbl_ |
11) Winforms Library - Advanced |
|
GenerateWinLibrary | 生成winform的控件库 |
{FKField.name}Source | 建立有外键的列可以查询到关联表的数据 |
{table.name}DataSource | EntityDatasource 实体数据源 |