Cyq. Data layer Framework CYQ. The data framework uses four maction additions and deletions to change

Source: Internet
Author: User

Summary of the content of this article

This article continues the previous article, this section describes all additions and deletions related operations.
1 : Add Data Insert Method
2
: Deleting a data Delete method
3
: Updating the Data Update method

One: Add action

Method Prototypes:
Public bool
Insert ()
Public bool Insert (bool autosetvalue)
Public bool Insert (bool autosetvalue, insertoption option)

Example 1:

using (maction action = new maction (tablenames.users)) {
Action. Set (Users.nickname, "Passing Autumn");//Non-UI type set value
action. Ui. Getfrom (txtusername)//ui type set value if (action. Insert ())         { int id=action . Get<int> (users.id);//Retrieve the primary key ID after insertion         }
}

Example 2:[usually only action. Insert (True) one line]

using (maction action = new maction (tablenames.users)) { action. Set (Users.nickname, "Passing Autumn");//Non-UI type set value action. Getfrom (txtusername)//ui type set value
action. Ui. Setautoprefix ( "ppt");//Set the control prefix to set multiple
action. Insert (True )///In addition to the assigned table fields, the values are automatically taken from the request["ppt field".
}

Another: Setautoprefix set automatic prefix method (default 4: null, TXT, DDL, CHB)

method Prototype: public void setautoprefix (string autoprefix, params string[] otherprefix)

Customizable settings multiple prefixes are shown for example:

action. Setautoprefix ("ppt", "Nud", "Lab");

Example 3:

using (maction action = new maction (tablenames.users)) { return action. Insert (False,insertoption.id );//after inserting, do not need to retrieve the self-increment ID
}

Insertoption Enumeration Description:

<summary>
The return value option for inserting data
</summary>
public enum Insertoption
{
<summary>
Use this key: after inserting data [MSSQL returns ID, other database does not return ID]
</summary>
None,
<summary>
Use this key: The ID is returned when the data is inserted.
</summary>
Id
<summary>
Use this key: After inserting the data, the data rows are populated with the query based on the return ID. [Default options]
</summary>
Fill,
}

Two: delete operation

Method Prototypes:
Public bool
Delete ()
Public bool Delete (object where
)

Example 1:

using (maction action = new maction (tablenames.users)) {
Action. Delete (1);
}

Example 2:

using (maction action = new maction (tablenames.users)) {
Action. Delete ("the"
);//Bulk Delete
}

Three: Update operation

Method Prototypes:
Public bool
Update ()
Public bool Update (object where
)
Public bool Update (Object where, bool
Autosetvalue)

Example 1:

using (maction action = new maction (tablenames.users)) {
action. Set (Users.password, "http://cyq1162.cnblogs.com"
);
Action. Update (1);//renew password with ID 1

}

Example 2:

using (maction action = new maction (tablenames.users)) {
Action. Set (Users.password, "http://cyq1162.cnblogs.com"
);
Action. Update ("Username= ' passing Autumn '"
);
}

Example 3:

using (maction action = new maction (tablenames.users)) { action. Set (Users.nickname, "Passing Autumn");//Non-UI type set value action. Update ("Id=1", True )///In addition to the assigned table fields, the values are automatically taken from the request["field".
}

Cyq. Data layer Framework CYQ. The data framework uses four maction additions and deletions to change

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.