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!