Xcodefactory3.0 full strategy-Basic Ideas

Source: Internet
Author: User
The main goal of xcodefactory is to free developers from SQL statements and data layers. That is to say, after xcodefactory is used, developers do not have to worry about anything on the data layer, all you have to do is maintain the xcf file-The xcodefactory project file. An xcf file corresponds to one of your vs files.. Net project.
With the xcf file in hand, I can use xcodefactory to automatically generate tables in the database, all data object classes, and Data Metadata classes. Therefore, to modify the structure of a table in a database, you only need xcodefactory to open the xcf file, modify the corresponding content, click the generate button, and re-compile your vs project.

You may already know something. Yes, the idea is that a vs. Net project corresponds to an xcf file, that is
Vs. Net project's data layer "=" xcf file "=" (multiple) Physical Databases

The so-called data object class can be said to be a simple data structure. All its attributes correspond to the fields in the corresponding database table one by one. Note that it is "one-to-one correspondence ", the database type is also converted to the corresponding C # type, such as nvarchar to string, image to byte array, and so on.

An object (an instance of a Data Object Class) corresponds to a record in the database table.

Nowadays, there are already many automatic generation tools for the data layer. The authors of these tools have their own solutions for the design of the data layer, and xcodefactory is no exception. For example, some implement the database access operation as the public method of the Data Object (corresponding to a table in the database), and some implement the Data Object independently from the visitor. Xcodefactory adopts the following idea.

Based on the example above, student class corresponds to the studata handler class studentsqldealer used for conversion between or, such as studentsqldealer. the getobjects method converts qualified records in the database to the student array and returns the result, while studentsqldealer. insert (student1) is used to insert a record into the database. Data access is not provided as a public Method for Data Objects because:
(1) It is not intuitive enough and its meaning is vague.
For example, student. Save means to insert yourself into the database, and student. Update means to update the corresponding records in the database. So how do users know which one to call? Should student. isexist be called before each call to determine whether the corresponding record exists?

(2) Some operations are hard to express.
For example, do I use student. insertbatch for batch inserts? Obviously, insertbatch is not a function of student at all. Studentsqldealer. insertbatch clearly expresses the meaning.

Based on the above two reasons, the Data Object Class and the visitor are independent. This can also bring additional benefits:
(1) It is easier to switch the database type. Using the reflection factory, you can change the database type by modifying the configuration file.
(2) When the database access interface changes, the data object class does not need to be modified.
These will be reflected in the following examples.

Xcodefactory3.0 full Guide directory

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.