http://mybloggers.blog.163.com/blog/static/1003865092011031101346648/#_Toc237544659
目录
1 CodeSmith.BaseTemplates. 4
1.1 Batch. 4
1.1.1 属性... 4
1.1.2 方法... 4
1.2 OutputFileCodeTemplate. 4
1.2.1 属性... 4
1.2.2 方法... 4
1.3 ScriptError 5
1.3.1 方法... 5
1.4 ScriptErrorCollection. 5
1.4.1 属性... 5
1.4.2 方法... 5
1.5 ScriptResult 5
1.5.1 属性... 5
1.5.2 方法... 5
1.6 ScriptUtility. 5
1.6.1 属性... 6
1.6.2 方法... 6
1.7 SqlCodeTemplate. 6
1.7.1 属性... 6
1.7.2 方法... 6
1.8 StringUtility. 7
1.8.1 属性... 7
1.8.2 方法... 7
2 SchemaExplorer 7
2.1 DatabaseSchem.. 7
2.1.1 属性... 7
2.1.2 集合... 8
2.2 TableSchema. 8
2.2.1 属性... 8
2.2.2 方法... 8
2.2.3 集合... 8
2.3 CommandSchema. 9
2.3.1 属性... 9
2.3.2 集合... 9
2.4 ViewSchema. 9
2.4.1 属性... 9
2.4.2 方法... 9
2.4.3 集合... 10
2.5 ColumnSchema. 10
2.5.1 属性... 10
2.6 ParameterSchema. 10
2.6.1 属性... 10
2.7 ViewColumnSchema. 11
2.7.1 属性... 11
2.8 TableKeySchema. 11
2.8.1 属性... 11
2.8.2 集合... 11
2.9 IndexSchema. 11
2.9.1 属性... 11
2.9.2 集合... 12
2.10 ExtendedProperty. 12
2.10.1 Table. 12
2.10.2 View.. 12
2.10.3 Command. 12
1 CodeSmith.BaseTemplates
基础模版类。
1.1 Batch
1.1.1 属性
名称 |
说明 |
Content |
|
LineCount |
|
StartLineNumber |
1.1.2 方法
名称 |
说明 |
Finalize |
在一个对象再次创建之前获得空闲资源并且执行其他的清空操作 |
MemberwiseClone |
建立现有对象的副本 |
1.2 OutputFileCodeTemplate
模版通过继承此类能够在生成过程中把他们的输出保存到文件中
1.2.1 属性
名称 |
说明 |
CodeTemplateInfo |
得到当前模版的信息 |
OutputFile |
此属性用来指定一个保存模版输出的输出文件名 |
Progress |
提供一种方式汇报模版的执行进程 |
Response |
模版输出返回流。此属性可以在程序中写出流 |
State |
模版实例的状态 |
ValidationErrors |
得到模版的错误 |
1.2.2 方法
名称 |
说明 |
CopyPropertiesTo |
把匹配的属性拷贝到另一个代码模版实例中 |
GetCodeTemplateInstance |
重载,得到指定模版的实例 |
GetFileName |
为模版的输出得到一个默认的名字 |
GetProperties |
得到模版的所有属性 |
GetProperty |
得到模版的指定属性 |
GetRequiredProperties |
得到模版上所有必要的属性 |
GetType |
得到当前实例类型 |
ParseDefaultValue |
解析属性的默认值 |
SavePropertiesToXml |
以XML保存属性 |
SavePropertiesToXmlFile |
保存属性到一个XML文档 |
SetProperty |
重载,保存指定的属性值 |
ToString |
1.3 ScriptError
在脚本执行中出现一个错误
1.3.1 方法
名称 |
说明 |
Finalize |
在一个对象再次创建之前获得空闲资源并且执行其他的清空操作 |
MemberwiseClone |
建立现有对象的副本 |
1.4 ScriptErrorCollection
1.4.1 属性
1.4.2 方法
1.5 ScriptResult
一个脚本的运行结果包含一些已经发生的错误
1.5.1 属性
1.5.2 方法
1.6 ScriptUtility
这个类能用来在数据库上执行Sql脚本。
1.6.1 属性
名称 |
说明 |
ConnectionString |
执行脚本时使用此连接字符串 |
Script |
执行的脚本 |
1.6.2 方法
名称 |
说明 |
ExecuteScript |
重载,执行脚本 |
1.7 SqlCodeTemplate
继承此类的模版当从一个Sql数据源生成代码时能够获得很多有用的帮助方法
1.7.1 属性
名称 |
说明 |
CodeTemplateInfo |
得到当前模版的信息 |
OutputFile |
此属性用来指定一个保存模版输出的输出文件名 |
Progress |
提供一种方式汇报模版的执行进程 |
Response |
模版输出返回流。此属性可以在程序中写出流 |
State |
模版实例的状态 |
ValidationErrors |
得到模版的错误 |
1.7.2 方法
名称 |
说明 |
CopyPropertiesTo |
把匹配的属性拷贝到另一个代码模版实例中 GetCamelCaseName Returns a camel cased name from the given identifier. |
GetCodeTemplateInstance |
重载,得到指定模版的实例 |
GetCSharpVariableType |
基于给定列返回C#的变量类型 |
GetFileName |
为模版的输出得到一个默认的名字 |
GetMemberVariableDeclarationStatement |
重载,返回C#成员变量声明语句 |
GetMemberVariableDefaultValue |
基于一个列的数据类型返回一个默认值 |
GetMemberVariableName |
为一个给定标示返回一个C#成员变量名 |
GetProperties |
得到模版的所有属性 |
GetProperty |
得到模版的指定属性 |
GetPropertyName |
返回指定列的公有属性的名字 |
GetReaderMethod |
Returns the name of the typed reader method for a given column. |
GetRequiredProperties |
得到模版上所有必要的属性 |
GetSpacedName |
Returns a spaced out version of the identifier. |
GetSqlDbType |
返回一个给定列的SqlDbType |
GetSqlParameterExtraParams |
为ADO的参数声明生成额外的参数 |
GetSqlParameterStatement |
重载,返回给定列的T-Sql的参数声明 |
GetSqlParameterStatements
|
重载,给指定列加一个参数到ADO对象生成一个指定声明(Generates an assignment statement that adds a parameter to a ADO object for the given column. ) |
GetValidateStatements |
基于某列生成一组确认声明 |
IncludeEmptyCheck |
确定一个给定列是否可以为空 |
IncludeMaxLengthCheck |
确定一个给定列的类型是否需要最大长度的定义 |
IsUserDefinedType |
确定是否一个给定列用了一个UDT(用户定义类型) |
ParseDefaultValue |
解析属性的默认值 |
SavePropertiesToXml |
以XML保存属性 |
SavePropertiesToXmlFile |
保存属性到一个XML文档 |
SetProperty |
重载,保存指定的属性值 |
1.8 StringUtility
多种处理string型的方法
1.8.1 属性
1.8.2 方法
2 SchemaExplorer
数据库架构信息。
2.1 DatabaseSchem
2.1.1 属性
名称
说明
ConnectionString
一般填写类似于ADO.NET的连接字符串
Name
数据库名称
Provider
驱动程序提供者,一般实例化一个SqlSchemaProvider对象
2.1.2 集合
名称
说明
Commands
所有存储过程集合
Tables
所有表的集合
Views
所有视图的集合
2.2 TableSchema
2.2.1 属性
名称
说明
Name
表名
Database
所在数据库
DataCreated
创建日期
FullName
全名
HasPrimaryKey
是否有主键
Owner
所有者
PrimaryKey
主键信息
2.2.2 方法
名称
说明
GetTableData
获取表中所有数据,结果为DataTable
2.2.3 集合
名称
说明
Columns
所有列集合
ForeignKeyColumns
所有外键列的集合
ForeignKeys
外键信息的集合
Indexes
所有索引的信合
Keys
所有主键和外键的列的集合
NonKeyColumns
所有非主键外键列的集合
NonForeignKeyColumns
所有非外键列的集合
NonPrimaryKeyColumns
所有非主键列的集合
PrimaryKeys
主键信息的集合
2.3 CommandSchema
2.3.1 属性
名称
说明
Name
存储过程名
FullName
全名
Database
所在数据库
DataCreated
创建日期
Owner
所有者
ReturnValueParameter
返回值参数,SQLSERVER中似乎取不到
CommandText
存储过程的内容源代码
2.3.2 集合
名称
说明
AllInputParameters
所有的输入参数集合,有可能包括即是输入又是输出的参数
AllOutputParameters
所有输出参数的集合,有可能包括即是输入又是输出的参数
CommandResults
存储过程的查询结果集合
InputOutputParameters
输入输出参数的集合
InputParameters
所有输入参数的集合
OutputParameters
所有输出参数的集合
Parameters
所有参数的集合
NonReturnValueParameters
除了返回值之外的参数的集合
2.4 ViewSchema
2.4.1 属性
名称
说明
Name
视图名
FullName
视图全名
Database
所在数据库
DataCreated
创建日期
Owner
所有者
ViewText
视图源代码
2.4.2 方法
名称
说明
GetViewData
得到视图中的数据,返回类型为DataTable
2.4.3 集合
名称
说明
Columns
视图中所有列的集合
2.5 ColumnSchema
2.5.1 属性
名称
说明
Name
列的名称
NonDBNull
是否允许为空
Database
所在数据库
DataType
内部表示的数据类型
IsForeignKeyMember
是否为外键
IsPrimaryKeyMember
是否为主键,通用
IsUnique
是否唯一
NativeType
数据库中的数据类型
Precision
精度
Scale
小数位数
Size
列的长度
SystemType
当前列在所用语言中的类型
Table
所在的表
2.6 ParameterSchema
参数结构
2.6.1 属性
名称
说明
Name
参数名称
NonDBNull
是否为空
Command
所在存储过程名
Database
所在数据库
Direction
参数的类型:输入,输出,输入输出,返回值
NativeType
数据库中的数据类型
Size
长度
Precision
精度
Scale
小数位数
SystemType
当前列在所用语言中的类型
2.7 ViewColumnSchema
视图列的结构
2.7.1 属性
名称
说明
Name
视图的名称
NonDBNull
是否为空
View
所在的视图
Database
所在的数据库
NativeType
SqlServer中的类型
Size
长度
Precision
精度
Scale
小数位数
SystemType
当前列在所用语言中的类型
2.8 TableKeySchema
表中键结构
2.8.1 属性
名称
说明
Name
表的键的名称,即约束名称
Database
所在数据库
ForeignKeyTable
有外键的表,即子表
PrimaryKeyTable
主键表,即主表
PrimaryKey
主表的主键信息
2.8.2 集合
名称
说明
PrimaryKeyMemberColumns
当前键信息中主键的成员列集合,即主表中的主键的列的集合
ForeignKeyMemberColumns
当前键信息中外键的成员列集合,即子表中某个外键的列集合
2.9 IndexSchema
索引的结构
2.9.1 属性
名称
说明
Name
索引名称
Table
所在表
DataBase
所在数据库
Is
是否聚集索引
IsPrimaryKey
是否为主键索引
IsUnique
是否为唯一索引
2.9.2 集合
名称
说明
MemberColumns
索引的列集合
2.10 ExtendedProperty
扩展信息
2.10.1 Table
名称
说明
CS_isIdentity:
是否为标识符,不支持Access
CS_isComputed
是否为计算列
CS_isDeterministic
是否确定
CS_IdentitySeed
标识列种子数
CS_IdentityIncrement:
标识列递增量
CS_Default
列的默认值
CS_isRowGuidCol
2.10.2 View
名称
说明
CS_isIdentity:
是否为计算列
CS_isDeterministic
是否确定
2.10.3 Command
名称
说明
CS_Default
存储过程的默认参数