CYQ. Data lightweight Data access layer (2) constructing Data units (I)

Source: Internet
Author: User

DataTable, how rich are you:

Open reflector.exe, press F3 to search, enter DataTable, double-click positioning, right-click, after Disassemble,

Quietly click the bottom Expand Methods, and copy it out with ease before we can find out .. Over 6000 lines of code

The commonly used DataTable class is implemented using more than 6000 lines of code. As we wrote before, a class is written to more than one thousand lines, which makes it a bit too much.

See little witch!

 

 

Resolution:

Of course, it doesn't mean that the more code a class, the worse the performance. At least we will continue to use it when there are so many people.

The reason is that there are many groups.

For the current data access layer, we do not need so many features. We only need the most common features,

You can directly bind a table to a control and access the database types of data rows, data columns, data units, and data,

 

 

Therefore:

We started the customization. In the customization, we do not inherit things related to the DataTable. We build our own lightweight Table class step by step.

 

 

The following describes how to construct your own MDataTable series classes:

1. Cell: MDataCell

First, let's look at a row of data that we commonly use, such:

Description:

At a glance on the image, the first row is the column header, followed by all data rows. What should the cell contain? This is actually a problem. If we look at the interface, a single cell only has Value,

However, if it is only Value, it lacks meaning because you don't know what column it belongs to. Simply put, if there is no column header, what is the meaning of your data, it's hard to understand,

Unless this value has a deep explanatory meaning.

 

Note:

Therefore, a cell should also contain a column header explanation. This is a reality. If a cell is composed of headers and values, each row of data will contain repeated column headers.

Let's take a closer look at the figure. In fact, there is only one column header, and the rest are values... so here, there is a question that can be considered.

Cells must be composed of headers and values. However, to ensure that there are more data and only one header exists, how can this problem be converted into a designed class ??

 

 

Next section!

 

 

 

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.