Data access layer (DAL)

Source: Internet
Author: User

Establish a data access layer, that is, the lowest layer of the Three-layer system. It should include some methods to deal directly with physical data storage spaces (not simply databases. This is a common method, such as sqlhelper in this example. Of course, if you need more versatility, You can abstract it and create a factory or something.

Here, sqlhelper is no longer cumbersome, and the purpose of this article is no longer here.

When an object class is created, the simplest object class can be regarded as a class to express the Logical Data Relationship of the physical source, such as the relationship between tables and fields.

Public class messageboardinfo
{

Public messageboardinfo ()
{

}

Private string _ messagebody;

Public String messagebody
{
Get {return _ messagebody ;}
Set {_ messagebody = value ;}
}
Private datetime _ messagetime;

Public datetime messagetime
{
Get {return _ messagetime ;}
Set {_ messagetime = value ;}
}

}

Here, we can see that it actually containsArticleThe body messagebody and the release time messagetime.

Create a method in the messages class of the data access layer to add and query methods.

Public messageboardinfo [] geimessage ()
{
...
}
Public void savemessage (messageboardinfo mbinfo)
{
...
}
We can see that in data access, we only deal with physical data in big ways, rather than considering data correctness, display, location, or something.

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.