Teach you how to write a code generator (also an ORM)

Source: Internet
Author: User
Because the ORM still needs to be configured and entityobject is still required, it is inevitable to repeat the work. Here we will briefly look at how to implement CodeGenerator to reduce our labor intensity.
To put it bluntly, the principle of the Code Generator is quite simple. In a word, the main point is to obtain information about tables and fields.
Here we use sqlserver database as an example to see how to obtain
Obtain the tables and table information. Use the sp_tables stored procedure.
You can use sp_columns to obtain information about fields in a table.
Another way is to read the System View or system table.
After the metadata of the database is obtained, the generated code is a small case where the loop is followed again.
Note that it is recommended to read the system view (in the master database), which is more accurate. The execution results of sp_columns between 2000 and 2005 are different.

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.