Currently,In enterprise development, development teams generally choose one type.ORMTo improve the development efficiency and maintainability of the system. I useSQL Server 2005AndIbatis. netDevelopedDa GeneratorTool. The following describes how to access the metadata of a database.SQL Server 2005Stored Procedures in:
Stored ProcedureSp_helpdb
--Used to obtain all(Or a specific)Database Information,For exampleName, db_size, ownerAnd so on
--You canSQL Server 2005Run"Exec Sp_helpdb"And"Exec Sp_helpdb@ Dbname='Master'",Analyze the execution result by yourself.
Stored ProcedureSp_tables
-- Used to obtain the specified ( Or the current ) All ( Or specify the table name ) Database objects ( Including tables, views, and system tables ) Information
--Parameters include::
-- @ Table_name (Type:Nvarchar(384),Default Value:Null)
Table Name
-- @ Table_owner (Type:Nvarchar(384),Default Value:Null)
Table owner
-- @ Table_qualifier (Type:Sysname,Default Value:Null)
Database Name
-- @ Table_type (Type:Sysname,Default Value:Null)
Database Object Name
If You Want to query master database users DBO all tables , the corresponding T-SQL below
Exec Sp_tables@ Table_qualifier=N'Master',
@ Table_owner=N'Dbo',
@ Table_type='''Table '''
Stored ProcedureSp_columns
-- used to obtain the specified ( or the current ) all columns in the specified table of the specified user in the database context ( or specify the column ) Information
--Parameters include::
-- @ Table_qualifier, @ table_owner, @ table_name,The type and default value are the same.Stored ProcedureSp_tablesParameters in
-- @ Column_name (Type:Nvarchar(384),Default Value:Null)
Specifies the column name. If this parameter is not specified, information about all columns is returned.
If You Want to query master database users DBO table spt_fallback_db information about all columns, then the corresponding T-SQL as follows :
Exec Sp_columns@ Table_qualifier=N'Master',
@ Table_owner=N'Dbo',
@ Table_name=N'Spt _ fallback_db'
Da GeneratorAlso usedCodedomAutomatic GenerationCode.
If you are interested in codedom, you can learn the Microsoft msdn documentation:
Http://msdn.microsoft.com/en-us/library/f1dfsbhc.aspx
Finally, you can obtain the name of the database table column from the database.CodedomTechnology to generate the corresponding entity class,IbatisUsedInsertStatement,ResultmapIng. ToolsDa GeneratorThese functions are implemented.The attachment is executable.Program(To connect to the database, you must modify the connection string in the configuration file.).
Http://files.cnblogs.com/fuhongwei041/DAGenerator.rar
It's the end. Thank u for your reading.