CYQ. Data lightweight Data layer ultimate upgrade (2)

Source: Internet
Author: User

In the previous article: CYQ. Data lightweight Data layer (1), we introduced the basic class libraries and usage.

 

Although it seems calm in the previous message, it is not hard to imagine that everyone should not take a glance at the scene:

A very heavy knot has been lingering in the hearts of many developers: entity classes.

Everyone seems to be sorting out data layer frameworks without entity classes, just because they get used to ORM before?

 

In fact, I remember that when I first completed the setup, there were also entity classes:

I still remember that a long time ago, I tried to copy the CQ-Space of the QQ Space and used CodeSmith to generate the entity class [which contained the add, delete, modify, and query] to operate the database,

I also felt the development pleasure of smart prompts brought by entity classes!

Let's take a look at a few distant figures here:

1: Space main site Logo

2: spatial main site collection, User ranking, and weather forecast

3: Background Management Interface

4: main user space interface:

5. User photos and photos

 

6. user logs and publishing logs

7. User music

8: User chat room

 

 

There are a lot of images on it, and I miss it a little bit more ^-^! Go back to the topic:

Later, when I joined the first company, an old programmer took me to project using pure SqlHelper + Stored Procedure + code generation tools, and completely forgot the existence of the entity class!

Later, I joined the new technical director. I developed this framework when developing the blog series and applied it to projects. There was no entity class in the middle!

Maybe there is no concept of preemptible, so there is no entity class and it does not affect me much. Instead, it is a bit of a list of entity classes;

 

Some colleagues in the middle probably cannot do without the entity class. Therefore, on the basis of this framework, an additional layer of entity class calling is added, and then its entity class is happily called at the interface layer!

I was used to the development of this framework. Even when the technical director developed a New ORM framework, I was a little disgusted. After all, the concept of first-in-first-priority was still very strong at that time.

 

After a few years, I have not split entity classes, but I have also written several ORM-type frameworks with entities and a bunch of stored procedures, there are also entity + reflection combinations. Currently, it is also an ORM type.

All the way back, in fact, it doesn't matter which kind, simple and easy to use is the right thing!

Therefore, when this framework was re-launched, I overwrote a lot of code to make it easy to use and easy to configure!

 

In fact, what everyone is struggling with is that when the entity class "clicks", there are smart prompts for attributes, or is it for ORM?

At the beginning, I only had the "entity class hitting prompt" function;

 

In the previous section, although I have carefully transformed it and added enumeration to realize the Smart Tips of "hitting", it still seems not so friendly. We still need to split it apart a little more.

So today, I "inserted two wings" for it to get it out of the index-type assignment from the outer layer and embark on the bright road of returning!

 

As a result, the code is concise again. See no index or enumeration:

1: add

MAction action = new MAction (TableNames. CQ_Album); // parameter: enumeration table name
Action. GetFrom (txtUserId );
Action. GetFrom (txtAlbumType );
Action. GetFrom (txtAlbumName); action. Insert ();
Action. Close ();

 

2: Update:

MAction action = new MAction (TableNames. CQ_Album );
Action. GetFrom (txtAlbumName );
Action. Update ("id = 1 ");
Action. Close ();

 

3: Read data:

MAction action = new MAction (TableNames. CQ_Album );
If (action. Fill (1 ))
{
Action. SetTo (lblAlbumName );
Action. SetTo (lblAlbumType );
Action. Close ();
}

 

4: delete and query. The object is basically not involved. Just like in the previous section, no code will be added.

 

Is it inconvenient to see the above operations? If yes, you are welcome to provide more convenient operation methods to share with everyone!

 

All right, this article is over. Welcome to download and use: Click to download

 

 

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.