Introduction to data entity Layer

Source: Internet
Author: User

The data entity layer is used to encapsulate the data structure of an entity class. It is generally used to map data tables or views of a database to describe objects that exist objectively in the business.
When designing the data entity layer, you generally have the following options.
1. Dataset
2. xml
3. Use XML as the data structure source to generate a Unified Business Entity class.
4. serializable business entity classes.
5. serializable business entity classes with General crud operations.
The first two are too simple to describe here.
The third type is to write a complex and Unified Business Entity class. This class mainly reads the specified XML file and generates the corresponding business entity class. Using common databases

Tool to export the existing database structure as an XML file and put it in the specified location.ProgramRead the XML and generate the corresponding dataset for the operation. The advantage is that the program

It is completely isolated from the database and only related to the corresponding XML file. Therefore, it is highly independent. The downside is that there are too many things to consider. To fully implement reusability

It takes a lot of time. In addition, the configuration management requirements are very strict, mainly in the XML and Database Consistency. If you forget to update XML after updating the database,

Well, the consequences can be imagined. In addition, the system overhead increases, which has a certain impact on performance. (For some examples on the internet, refer)
The fourth implementation is relatively easy, but it requires a lot of work for general projects. However, using spdevelop can easily help you complete the work within 1 second, reducing the workload

Workload. The generated entity is as follows:

Using system;
Using system. Data. sqlclient;
Namespace spdevelop. Model
{

/// <Summary>
/// Role
/// </Summary>
Public class role
{
/// <Summary>
///
/// </Summary>
Public role ()
{
}
/// <Summary>
///
/// </Summary>
Public role (int32 RID)
{
This. rid = RID;

}
/// <Summary>
///
/// </Summary>
Public role (sqldatareader Dr)
{
This. rid = convert. toint32 (Dr ["RID"]);
This. Name = convert. tostring (Dr ["name"]);

}



# Region RID
Private int32 RID;
/// <Summary>
/// Role ID
/// Autoinc
/// PK
/// </Summary>
Public int32 RID
{
Get {return RID ;}
Set {rid = value ;}
}
# Endregion

# Region name
Private system. string name;
/// <Summary>
/// Role name
/// </Summary>
Public System. string name
{
Get {return name ;}
Set {name = value ;}
}
# Endregion


}
}

View detailed templates www.spdevelop.com

The fifth is to add basic CRUD operations to the fourth type.

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.