Xcodefactory3.0 full introduction-xcf conventions

Source: Internet
Author: User

Every programmer has his own coding habits. But to better use the code generated by xcodefactory, it is best to follow the xcf conventions in some styles/habits. Accept the xcf conventions with very few limits, and you will get a great return from xcodefactory!

The xcf conventions are as follows:
(1) Make sure that the first field of all database tables is the primary key and the primary key name is "ID ".
If you do not agree that each table has an ID primary key, you can leave a message to discuss with me. If you agree, strictly use the "ID" name instead of "studentid ".

(2) If there are "name" and "name" fields corresponding to "ID", use "name.
Every automatically generated data object class (corresponding to a database table) is overloaded with the tostring method. If the name field exists, a string in the "ID name" format is returned, otherwise, the ID value is returned. The benefits of doing so will be mentioned later.

(3) The database name, database table name, and field name must comply with the camel naming method.
For example, the birthdate field in the student table in the dataserver Database

(4) No. I will try again later :)

The code generated by xcodefactory also complies with the following conventions:
(1) The name of the Data Object Class is exactly the same as that of the database table. For example, the name of the data object class corresponding to the student table is also student.

(2) The data catalog class name format is: database table name + Database Type + dealer
Such as studentsqldealer, studentoracledealer, studentoledealer

(3) the attributes of the data object class are exactly the same as those of fields in the database table.
For example, if the student database table has a birthdate field, the corresponding student class has a birthdate attribute, a birthdate private variable, and a const string variable named _ birthdate, the purpose of _ birthdate is described later.

(4) Each database table corresponds to a folder with the same name, and contains two files: The data object class CS file and the data entity class CS file.
For example, the student. CS and studentdealer. CS files exist in the student folder. If you select to generate the UI, there will be two other UI-class files studentform. CS and studentmanageform. CS.

The following describes the generated data object class through a simple student example. The student table is described as follows:
Whether the field name type length is a primary key annotation (Chinese name)
Id int 4 true automatic number
Name nvarchar 20 false name
Age int 4 false age
Description nvarchar 50 false description

The generated data object class code is as follows:


// Xcodefactory Automatic Code Generator V3.0 beta1 Author: zhuweisky

Using system;
 
Namespace xcfexample. skyexample
{
Public class student
{
Public student ()
{
}

# Region fieldname, used to enhance static checks
Public const string _ id = "ID ";
Public const string _ name = "name ";
Public const string _ age = "Age ";
Public const string _ description = "Description ";
# Endregion


# Region ID
Private int id = 0;
/// <Summary>
/// Automatic ID
/// </Summary>
Public int ID
{
Get
{
Return this. ID;
}
Set
{
This. ID = value;
}
}
# Endregion

# Region name
Private string name = "";
/// <Summary>
/// Name
/// </Summary>
Public string name
{
Get
{
Return this. Name;
}
Set
{
This. Name = value;
}
}
# Endregion

# Region age
Private int age = 0;
/// <Summary>
/// Age
/// </Summary>
Public int age
{
Get
{
Return this. Age;
}
Set
{
This. Age = value;
}
}
# Endregion

# Region description
Private string description = "";
/// <Summary>
/// Description
/// </Summary>
Public String description
{
Get
{
Return this. description;
}
Set
{
This. Description = value;
}
}
# Endregion

# Region tostring
Public override string tostring ()
{
Return this. Id. tostring () + "" + this. Name. tostring ();
}
# Endregion
}
}

There are so many xcf conventions. On the basis of the xcf conventions, xcodefactory can work efficiently! 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.