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.