How the wildfish framework works: Data Layer

Source: Internet
Author: User

The function of the data layer is to encapsulate the Data Types of some columns and the relationships between the definitions and tables.
1. Dataset Encapsulation
Advantage: DataSet used for crud can be generated by tools. In fact, the encapsulated information is nothing more than mainkey addtionalkey and other information.
Definition:
Each data table generally has a primarykey,
For a single table, primarykey = mainkey
For multiple tables, the primary table's primarykey = mainkey, from the table's primarykey = mainkey + addtionalkey
Principle:
Not to mention a normal single table, you only need to set the mainkey information.
Set the addtionalkey of the slave table.
Because the dataset information is not used, we store the information in datacolumn. extendproperity.
Disadvantages:
Datarow must be used for each operation, and the type verification cannot be achieved.
During batch update/deletion, an SQL statement must be executed for each update/Delete row, which is time-consuming.
2. updateobject/deleteobject
As the name suggests, this is an update/delete object. It is used to create data that can be updated/deleted in a table. It can also add fixed conditions and variable conditions.
We constructed an object that exists for batch update/deletion. When updateobject/deleteobject is submitted, only one SQL statement is generated.

3. Entity
Reason:
It is inconvenient to use datarow. You cannot perform type and data correctness verification as soon as possible.
Basedataset has a getentity setentity createentity method to generate a simple object based on the datatable.
Each object can be regarded as a row.
In this way, we can use orderentity entity = orderdataset. orderdatatable. createentity ();
Entity. orderid = "xxxxxx ";
.........................
Orderdataset. orderdatatable. setentity (entity );
It is more convenient than datarow.
In addition, after dataset obtains all the data for the entities in the primary table, the entities in the primary table also use a set of entities from the table.
For (INT I = 0; I <orderentity. orderitementities. Count; I ++)
{
Orderitementity itementity = orderentity. orderitementities [I];
// Do something
}

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.