Tools for Automatically Generating entity classes and ibatis-related Configurations Based on the metadata in the database

Source: Internet
Author: User

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.
 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.