Use mygeneration to generate code

Source: Internet
Author: User

1. Connect to the database. The default settings dialog box is displayed when Myg is started for the first time. You can modify the settings in edit-default settings later. Default settings has three tabs. Modify the connection string in connection and modify the default template path and default output path in templates. For more help, see the default settings section in mygeneration help.
On the connection tab, select the database driver type. Basically, follow the example below to change the connection string. For example, add a password and do not modify the language ing file. Select the language type, do not modify the database ing file. Select the database type. After the connection test is successful, you can exit.

2. After exiting, The Myg interface is displayed. The menu and toolbar are displayed. You can view the navigation chapter in mygeneration help. The left side is the template browsing window. Myg provides two ways to view the installed template by name space or file directory. It is generally clear when you view the template by name space. The template name generally indicates the purpose of the template. The template extension generally indicates the language used to write the template. For example, the template written in VB is A. vbgen file, and the template written in JScript is A. jgen file. In the browser window, you can also view the online template library, open the template, and directly execute the selection template. For detailed usage of the template browser window, see the template browser section in mygeneration help.

3. Select a template to open the template. The template editing window appears on the right. For more information, see the template editor section. In the editing window, you can edit and save templates and execute templates. The editing window has five tabs:
Template code is the template code, which can be modified
Interface code is the interface code used to run the template. It can be modified.
Template source and Interface source do not understand what it is, but are read-only.
Output is the execution result output of the template, that is, the generated code.

4. Generate a stored procedure.
View the template in the namespace. For example, to generate the stored procedure of the SQL Server database, the template is SQL _storedprocs under microsoft_ SQL _server. You can choose vbgen or jgen, and the effect is the same.
-Open Template
-Click the execution button.
-In the pop-up interface, you can select databases and data tables as needed.
-Click OK.
-View the generated code on the output tab, copy the code to the SQL Server query window, and execute the code to create a stored procedure.

5. Generate object classes.
There are a series of templates in the C # namespace:
Csharp_ SQL _doodads_businessentity is used to generate an entity abstract class of a table.
Csharp_ SQL _doodads_concreteclass is used to generate a specific class. You can also write it by yourself. In short, there is a little code: Inherit the abstract class. The relationships between classes and abstract classes can be rewritten and added.
Csharp_ SQL _doodads_view is a class used to generate a view. Because Myg does not support multi-table queries, you have to create a view.
Csharp_doodads_storedproc is used to generate a method to call the stored procedure.
Csharp_ SQL _bussinessobject to be studied
The process is similar to the stored procedure generation. The difference is that the generated class file can be used after it is added to the project for compilation.

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.