With the data structure unit DataCell, data unit rows are easy to write, because all the data units add up and become data rows.
Therefore, we can easily write the following classes:
Code
/** // <Summary>
/// A row of data
/// </Summary>
Public class MDataRow: List <MDataCell>
{
Public MDataRow ()
: Base ()
{
}
Public MDataRow (int capacity)
: Base (capacity)
{
}
}
Look, few lines of code
Now, we add several common attributes to the row, such as the name of the table to which the row belongs, as well as the structure of accessing its columns from the row. By the way, we add a database link string.
As follows:
Code
Common Access attributes # common region access attributes
Private string _ TableName;
/** // <Summary>
/// Database table name
/// </Summary>
Public string TableName
{
Get
{
Return _ TableName;
}
Set
{
_ TableName = value;
}
}
Private string _ ConnectionString;
/** // <Summary>
/// Database link string of the table to which the table belongs
/// </Summary>
Public string ConnectionString
{
Get
{
Return _ ConnectionString;
}
Set
{
_ ConnectionString = value;
}
}
Private MDataColumn _ Columns = null;
/** // <Summary>
/// Data column set
/// </Summary>
Public MDataColumn Columns
{
Get
{
If (_ Columns = null)
{
_ Columns = new MDataColumn (base. Count );
For (int I = 0; I <base. Count; I ++)
{
_ Columns. Add (base [I]. DataStruct );
}
}
Return _ Columns;
}
}
# Endregion
OK. Now the attribute is added. Add a clone method by the way.
Code
Clone # region clone
Public MDataRow Clone ()
{
MDataRow dataRow = new MDataRow (base. Count );
For (int I = 0; I <base. Count; I ++)
{
MDataCellStruct mcb = base [I]. DataStruct;
MDataCell mdc = new MDataCell (ref mcb );
Mdc. Value = base [I]. Value;
DataRow. Add (mdc );
}
DataRow. ConnectionString = this. ConnectionString;
DataRow. TableName = this. TableName;
Return dataRow;
}
# Endregion
So far, the data row has been built