Introduction to the SchemaExplorer attribute in CodeSmith, schemaexplorer
The connection between CodeSmith and the database. In CodeSmith, a self-contained Assembly SchemaExplorer. dll is included. Classes in this Assembly are mainly used to obtain the structures of various objects in the database.
<% @ Property Name = "SourceDataTable" Type = "SchemaExplorer. TableSchema" Optional = "False" Category = "Context" Description = "table Name" %>
<% @ Property Name = "SourceDataDB" Type = "SchemaExplorer. databaseSchema "Optional =" False "Category =" Context "Description =" "OnChanged =" "Editor =" "EditorBase =" "Serializer =" "%>
<% @ Assembly Name = "SchemaExplorer" %>
<% @ Import Namespace = "SchemaExplorer" %>
Structures and functions of main classes in SchemaExplorer:
DatabaseSchema
Attribute:
ConnectionString: Generally, enter a connection string similar to ADO. NET.
Name: Database Name
Provider: The driver Provider. It is generally instantiated as a SqlSchemaProvider object.
Set:
Commands: a collection of all stored procedures
Tables: a set of all Tables
Views: a set of all Views
TableSchema
Attribute:
Name: Table Name
Database: Database
DataCreated: date of creation
FullName: Full name
HasPrimaryKey: whether a primary key exists
Owner: Owner
PrimaryKey: primary key information
Method: GetTableData: get all the data in the table. The result is DataTable.
Set:
Columns: All column Sets
ForeignKeyColumns: a set of all foreign key columns
ForeignKeys: a set of foreign key information
Indexes: the combination of all Indexes
Keys: a set of all primary key and foreign key columns
NonKeyColumns: a set of all non-primary key foreign key columns
NonForeignKeyColumns: a set of all non-foreign key columns
NonPrimaryKeyColumns: a set of all non-primary key columns.
PrimaryKeys: a set of primary key information
CommandSchema Stored Procedure Structure
Attribute:
Name: Name of the stored procedure
FullName: Full name
Database: Database
DataCreated: date of creation
Owner: Owner
ReturnValueParameter: Return Value parameter, which does not appear to be available in SQLSERVER
CommandText: source code of Stored Procedure content
Set:
AllInputParameters: a set of all input parameters, which may include parameters that are both input and output.
AllOutputParameters: a set of all output parameters, which may include parameters that are both input and output.
CommandResults: a set of query results for Stored Procedures
InputOutputParameters: Set of Input and Output Parameters
InputParameters: a set of all input parameters
OutputParameters: a set of all output parameters
Parameters: a set of all Parameters
NonReturnValueParameters: set of parameters other than return values
ViewSchema View Structure
Attribute:
Name: View Name
FullName: view full name
Database: Database
DataCreated: date of creation
Owner: Owner
ViewText: view source code
Method: GetViewData: Get the data in the view. The return type is DataTable.
Set: Columns: Set of all Columns in the view
ColumnSchema Column Structure
Attribute:
Name: column Name
NonDBNull: whether to allow null
Database: Database
DataType: Internal data type
IsForeignKeyMember: whether it is a foreign key
IsPrimaryKeyMember: whether it is a primary key.
IsUnique: unique or not
NativeType: Data Type in the database
Precision: Precision
Scale: number of decimal places
Size: Column Length
SystemType: Type of the current column in the language used
Table: Table
ParameterSchema parameter structure
Attribute:
Name: Parameter Name
NonDBNull: NULL
Command: name of the stored procedure
Database: Database
Direction: parameter type: input, output, input and output, Return Value
NativeType: Data Type in the database
Size: Length
Precision: Precision
Scale: number of decimal places
SystemType: Type of the current column in the language used
Structure of ViewColumnSchema view Columns
Attribute:
Name: View Name
NonDBNull: NULL
View: View
Database: Database
NativeType: Type in SqlServer
Size: Length
Precision: Precision
Scale: number of decimal places
SystemType: Type of the current column in the language used
Table keyschema
Attribute:
Name: Name of the table key, that is, the constraint Name.
Database: Database
ForeignKeyTable: a table with a foreign key, that is, a subtable.
PrimaryKeyTable: primary key table, that is, the primary table
PrimaryKey: primary key information of the primary table
Set:
PrimaryKeyMemberColumns: set of primary key member columns in the current key information, that is, the set of primary key columns in the main table
ForeignKeyMemberColumns: The member column set of the current foreign key information, that is, the column set of a foreign key in the subtable.
IndexSchema Index Structure
Attribute:
Name: Index Name
Table: Table
DataBase: DataBase
Is: whether to clustered Index
IsPrimaryKey: whether it is a primary key index
IsUnique: whether it is a unique index
Set: MemberColumns: Index column set
ExtendedProperty Extension Information
Table:
CS_isIdentity: whether it is an identifier. Access is not supported.
CS_isComputed: whether it is a computed Column
CS_isDeterministic: Are you sure you want...
CS_IdentitySeed: Number of seeds in the identification Column
CS_IdentityIncrement: Number of ID column increments
CS_Default: column Default Value
CS_isRowGuidCol
View:
CS_isComputed: whether it is a computed Column
CS_isDeterministic:
Command:
CS_Default: the default parameter of the stored procedure.