Some differences and basic functions in the Oracle and MSSQL templates generated by codesmith

Source: Internet
Author: User

In my opinion, whether B/S or C/S is developed in any business system, the core focus should be on processing logic and high performance and security, the underlying layer and system structure should be well considered by the architect to form a unified style, and the front-end should be improved by the artist. Therefore, I think the system should be well done to save manpower. On the one hand, the system structure should be well considered in the early stage, on the other hand, use the codesmith class to generate the entire system. Especially in the CMS background, the structure is fixed. If ext is used for the front-end display, the front-end display can be quickly generated, and a small number of people can process the details, either at the front-end or for the end user, you can also generate basic structures with basic functions. I have seen that someone in the blog Park has released their own quick CMS generation system. After simple configuration, however, if codesmith is available, it is not only convenient to modify templates, you can also customize other classes to more accurately control the expected results.

Suddenly think of a "joke ":

There is a factory that produces soap. The soap produced by the factory is packed in a beautiful paper box.

However, there is a problem in the soap assembly line in the factory. There are always some paper boxes. After the assembly line, the soap is not loaded in and becomes an empty paper box.

It is a headache to pick up all these paper boxes. The factory director has added a lot of workers to check the assembly line, but the empty carton still exists.

On this day, the Director went to the Research Institute to find some experts and doctors. "You have developed a device for me to pick up all the empty cartons and I will leave 1 million"

Experts and doctors immediately set up a research team. after half a year of hard research and spent tens of millions of dollars, they finally created a photoelectric scanner. After the soap box was scanned by a photoelectric scanning device, the box without soap is scanned and picked out by the robot.

After finally solving this problem, the Director breathed a sigh of relief.

It is said that another small factory that produces soap has the same problem of empty cartons, and another factory manager is very angry.

On this day, the Director summoned several migrant workers and "Find a way to pick up the empty carton; otherwise, I will remove all of you"

Migrant workers gather together, think, and think about a full day ....

Last ....

A migrant worker buys a high-power fan...

Blow to the soap box on the assembly line, and then the empty soap box is blown away.

After finally solving this problem, the Director breathed a sigh of relief.

.......... I can only say that no one is right and no one is wrong. The small factory actually solves the problem at a low cost and saves money. Although the large factory has spent a lot of manpower and financial resources, however, it may bring about a technological revolution and other benefits.

Similar to software development, some products have similar structures and codes that can be generated using quick generators, which saves manpower costs. Some products have their own advantages after thinking for a long time and inventing Orm, however, when the system structure is stable, I think using a quick generator is also a good choice, especially for codesmith, which is based on the template generator and has excellent scalability.

This article details the technical aspects. Due to the project requirements a few days ago, we roughly analyzed codesmith, which was rarely used in the past. This time, we need to customize the code to generate a certain structure based on the Oracle database, make a note of the problem.

I did not quite understand <% @ Assembly name = "schemaexplorer" %>, <% @ import namespace = "schemaexplorer" %>, although this does not affect other usage, but I have never understood it yet. Now I know that assembly is like introducing an assembly. It can be used to process logic at runtime, just like the reference assembly of, import is like the using namespace in C #. If it is absent, compilation will fail.

<! -- # Include file = ". CS "-->, will automatically compile and load. CS class, which will be frequently used when a custom class is generated into a custom code. It will be compiled in real time, and smart prompts will automatically appear when the class is changed elsewhere.

<%> Automatic Execution At runtime
<% @ Register name = "dominservice" template = "domin/domain. service. CST "mergeproperties =" false "%>. Introduce domain like a user space. service. CST template. You can use rendertofile (.. generated. setproperty sets the template variable.

<% @ Property name = "classname" type = "string" Category = "context" Description = "Class Name Description" default = ". CS "%>, this add attribute. The CST file automatically identifies adding an input box that can input strings under the classification as context.

The most used <% @ property name = "sourcetable" type = "schemaexplorer. tableschema" Optional = "true" Category = "data" Description = "specify data table." %>

<% @ Property name = "sourcedatabase" type = "schemaexplorer. databaseschema "Optional =" true "Category =" data "Description =" specifies the database. "%>: it is essential for codesmith to develop data tables and database attributes and quickly generate code based on the database.

Of course, it is important that codesmith's schemaexplorer. dll file is located in the addins folder under the codesmith installation directory. It includes classes and methods used to generate databases.

It is important to generate a database type. The type fields generated by Oracle and MSSQL are different, which leads to frequent database generation. Different database file types are different, such as columnschema of a column in a table, MSSQL database uses the datatype attribute of the object to obtain the data type, and the value will have dbtype. double, dbtype. int64, dbtype. string, But Oracle is different. The nativetype attribute is used to obtain the data of the Oracle database. It is a string type result, such as clob, number, timestamp (6, since Oracle databases generally use the number type and do not use the int type, when converting a custom class to a specific type, you should refer to the precision, scale, and size of the columnschema object to determine. Scale is the number of digits accurate to the decimal point, such as number (6, 2), the scale attribute is 2, the size is used to calculate the length of the nvarchar2 type, such as nvarchar2 (100 ), the size attribute is 100, and the precision attribute is the exact number of digits before the decimal point. For example, if number (6, 2) is used, the precision attribute is 6, but the timestamp attribute has no value, it indicates the length of time, which can be 3, 6, 9, and 6 by default. The nativetype value is timestamp (6 ).

I have been busy recently, but I have not studied it very carefully, but I only use schemaexplorer for the front-end time. databaseschema automatically generates the entire Oracle database for a certain amount of research. After a while, I will take a closer look and hope to write a better and more detailed article.

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.