CYQ. Data lightweight Data layer V4.5 release [better user experience and better cache mechanism]

Source: Internet
Author: User

Preface:

Following the previous version: CYQ. Data lightweight Data layer V4.3 [added support for SQLite and MySQL databases] It has been nearly three months since now. In the middle, only V4.5beta is available for download, but it has not been officially released. Today, we finally want to release V4.5.

 

Next, let's take a look at the modification records of the new version.

Practical:
1: MAction: The Select method adds the overload: Select (string where );
2: FormatWhere processes the "is" keyword of "Parent is null". when processing the "order by" Statement, supplement it with "1 = 1 order ..."
3: add the Exists method to MAction.
4: added the ToEntity () method to the object for MDataRow.
5. Allow Null values to be updated to the database.
Transaction:
6: corrected the secondary RollBack error of the transaction, that is, two consecutive action. RollBack () calls ();
7: Modify the second start transaction.
Cache:
8: The Set method is added to the cache. If no value is Set, the method is added. If yes, the method is updated.
9: Modify the Cache mechanism to make it easier to view information. [clear Cache regularly]
Others:
10: MDataRow overrides the Clear () method. This method clears row data [that is, data is reset to Null]
11: Change the return value of the End method of aop to the MDataRow and MDataTable result sets.
12: fixed an error in OrmBase object conversion when the Value is DBNull. Value.

 

The following is a detailed explanation.

 

I. Introduction to practical functions

 

1: MAction: Select method adds overload: Select (string where)

 

In V4.3 and earlier versions, there are only two prototype methods:

Public MDataTable Select ()

Public MDataTable Select (int pageIndex, int pageSize, string where, out int rowCount)

A lot of people are used to it: Select ("where statement"); then they find that the where statement does not work, and all the data is found out. Then they struggle to ask this question.

 

Cause:

This overload method does not exist. Why not report an error? Confused.

Because the default Aop function is available, this parameter will be changed to the Aop parameter and passed to the Aop function for use. Most people do not know about Aop, so this problem is easily caused when used for the first time.

This time, we added a heavy load method to adapt to the public's usage habits and eliminate some confusion.

 

2: FormatWhere processes the "is" keyword of "Parent is null". when processing the "order by" Statement, supplement it with "1 = 1 order ..."

 

Question 1: action. Select (1, 10, "parent is null", out count );

Cause: the condition will fail because it is parsed as id = "parent is null.

Solution: action. Select (1, 10, "1 = 1 and parent is null", out count );

Possible cause: if there is a "=" or another symbol, it will not be parsed into the form of ID = xxx.

This IS resolution IS added to solve this problem.

 

Question 2: action. Select (1, 10, "order by id desc", out count );

Cause: the internal assembly is: "... where" + "order by id desc". The SQL statement syntax is incorrect.

Solution: action. Select (1, 10, "1 = 1 order by id desc", out count );

Possible reasons: composition: "... where +" 1 = 1 order by id desc ", so that the Assembly can pass normally.

This time, the prefix 1 = 1 is automatically added. You can directly write the order by statement with confidence in the future.

 

3: add the Exists method to MAction.

Early judgment: if (action. GetCount (where statement)> 0.

After this increase, Judge: if (action. Exists (where statement) {}. The expression is more advanced.

 

4: added the ToEntity () method to the object for MDataRow.

Many netizens still use entity classes.

In CYQ. Data, you can convert a table to an object class through action. Select (). ToList <T>.

However, this function has never been available for single row object classes. After adding this function, you can:

If (action. Fill (id) {UserInfo info = action. Data. ToEntity <UserInfo> ();}

It can be filled and converted to object class operations.

 

5. Allow Null values to be updated to the database.

The added feature allows you to set:

Action. Set (field, null) or action. Set (field, DBNull. Value );

Then Update the Null value back to the database through action. Update.

 

Ii. Transactions

 

6: corrected the error of secondary transaction RollBack [two consecutive calls of action. RollBack ()]

In earlier versions, calling action. RollBack () to roll back two transactions consecutively throws an exception,

Although you generally won't do this, you still have to deal with it.

 

7: fixed the second start transaction

In a MAction, If you end the transaction, you cannot start the second transaction.

After this correction, you can enable and disable transactions multiple times in a MAction.

 

Iii. Cache

 

8: 9: This version is upgraded to the latest version of the cache mechanism.

For instructions on Cache Usage, see:CYQ. Data framework cache help

 

Iv. Others

 

10: MDataRow override Clear () method: This method clears row data [that is, data is reset to Null]

 

11: Change the return value of the End method of aop to the MDataRow and MDataTable result sets.

 

12: fixed an error in OrmBase object conversion when the Value is DBNull. Value.

 

Finally:

 

CYQ. Data framework home: http://www.cyqdata.com/cyqdata

CYQ. Data framework download: http://www.cyqdata.com/download/article-detail-426

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.