CYQ. Data lightweight Data access layer (5) construct Data rows

Source: Internet
Author: User

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

 

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.