General Query System Based on Data Dictionary (iv) Design of entity classes 1

Source: Internet
Author: User

We divide the information in this module into two parts:ClassIs extracted from the database structure, and the first is the abstraction from the query construction process.

Before listing the contained classes, we need to note that, as in the previous analysis, each element has a representation of the database and the user. Here, I unified the representation of the database as a property.Exp,The Unified Expression for users isShow

I.Image extraction from the database structure.

1.Indicates the class of the table in the database.Querytable

2.Indicates the class of columns in the database.Querycol

3.Indicates the connected class in the database.Joincondition

4.Enumeration of Data TypesColshowtype,The four data types we analyzed in the second article (numerical value, date, String, status bit)

5.Indicates the status bit in the databaseColstatevalue;

6.For ease of operation, the image is extracted from the setJoincoditions, colstatevalues;

 

The class diagram is as follows:

Haha, because there are many reasons between the heroes in the garden, the code of the class will not be posted here, here onlyQuerycolBriefly.

As we have mentioned above, there are four data types, which are normal and most suitable. We should draw a unified knot for these four types of images, then implement four corresponding classes. AndQuerycolBut here, for the convenience of processing,QuerycolThe redundancy design is adopted, that is, some are similarC,C ++In some cases, only specific attributes are used.

One is used to process the attributes used in the date type.Format,As mentioned above, the date may beDatetimeStorage, you can also useVarcharStorage. In this case, after you perform operations, it is necessary to design a way to convert the data into columns that conform to the tables in the database. At this time, ourFormatIt takes effect.

The other is to process the attributes used in the status bit.ColstatevaluesAttribute, which isColstatevalueIn this case, it may not be clear. To give a column, such as a column,State,When it is0Indicates not processed.1It indicates that it has been processed.

This column hasColsatevaluesThe attribute of the first element.ShowIs"Unprocessed", ExpIs"0 ",TheShowIs"Processed", ExpIs"1 ";

Here To make the query results more intuitive.ColstatevaluesDesignGetstateThrough an elementExpFindShow.
Where are the additional information, We did not haveColstatestring? In different cases, just perform the processing.

To better understand the most effective method, paste itQuerycolThe constructor, hey

Code
InternalQuerycol (string exp, string show, querytable table,IntType, string values)

{

Exp=Exp;

Show=Show;

Datatable=Table;

This. Colshowtype=(Colshowtype) type;

If(Colshowtype=Colshowtype. State)

Colstatevalues= NewColstatevalues (values );

Else

Colstatevalues= Null;

If(This. Colshowtype=Colshowtype. Date)

Format=Values;

}

 Ah,ColstatevaluesYou can't forget, huh,CodeAs follows:

 

Code
Namespace Sftech. query. Entity
{
Public   Class Colstatevalues: List < Colstatevalue >
{

Private System. Collections. hashtable _ Hash;
Internal Colstatevalues (string values)
: Base ()
{
String [] Value = Values. Split ( New   Char [] { ' | ' }, Stringsplitoptions. removeemptyentries );
String Show;
String _ Value;
_ Hash =   New System. Collections. hashtable ();
For ( Int I =   0 ; I < Value. length; I ++ )
{
If (Value [I]. indexof ( ' & ' ) > =   0 )
{
Show = Value [I]. substring ( 0 , Value [I]. indexof ( ' & ' ). Trim ();
_ Value = Value [I]. substring (value [I]. indexof ( ' & ' ) + 1 ). Trim ();
}
Else
{
Show = Value [I]. Trim ();
_ Value = Value [I]. Trim ();
}

_ Hash. Add (_ value, show );
This. Add (NewColstatevalue (show, _ value ));
}

}

PublicString getstate (StringValue)
{

Return_ Hash [value]As String;

}

}
}

 

Here we have considered the use of strings and other non-numerical information as status bits ..

 

You can only write it in the first place.

The most important part to be written tomorrow is the design of some class libraries.

 

SeriesArticleConnection

I. SQL statement Structure Analysis

II. Analysis of the database composition structure.

3. Database design.

4. Entity Design

5.AlgorithmImplementation

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.