Note: Data Persistence Layer in devexpress

Source: Internet
Author: User

NoteDevexpressData Persistence Layer in

Persistent data objects:

Devexpress. xpo The data persistence objects in are mainly Xpobject And Xpbaseobject , The difference between them is Xpbaseobject Define a master ID From Xpobject The inherited object is stored in Oid Master ID If you already have a ready-made data table and a master ID From Xpbaseobject Derive your data persistence object.

Data access layer:

DevexpressThe data access layer in is encapsulated inSessionIs used by default.Devexrepss. xpo. session. defaultssessionYou can set the defaultSessionTo complete some basic settings of the data access layer, such as database link strings.

Data Operations:

There are many data operations, generally inXpbaseobjectAnd the query operation is not on the data persistence layer, but on the data layerDevexpress. DataHere, there are some very detailed data operations, you can perform bit operations on the data, you can also perform some advanced operations such as query classification. It's no wonder why some of its advanced controls, suchXforwartgrid, gridcontrolAnd so on. Of course, these data operation controls mainly use custom data to pass through the view to make the operation easy.

 

Some referencesCode:

1. Data Persistence class:

  Public   Class T_user: xpbaseobject
  {
Fields & Properties # Region Fields & Properties
Protected   String _ Loginname;
Protected   Int _ Userid;

Public   String Loginname
{
Get {Return This. _ Loginname ;}
Set {This. _ Loginname=Value ;}
}

[Key ( True )] // Use features to map data
Public   Int Userid
{
Get {Return This. _ Userid ;}
Set {This. _ Userid=Value ;}
}
Public T_user ()
{
// Use this constructor when you want to create a new object.
// Place here your initialization code.
This . _ Parentid =   - 1 ;
This . _ Regdate = Datetime. now;
}

Public T_user (session ): Base (Session) {
//This constructor is used when an object is loaded from a persistent storage.
//Do not place any code here.
}
}

2. Set the default Link

Xpodefault. connectionstring = Mssqlconnectionprovider. getconnectionstring ( " Server " , " Userid " , " PWD " , " DB " );

Of course, it also has other link drivers available.

3. test:

Try
{
Webad. Controls. t_user m_user =   New Webad. Controls. t_user ();
M_user.loginname =   " Apple " ;
M_user.password =   " Test " ;
M_user.save ();
}
Catch (Exception ex)
{
System. Diagnostics. Debug. writeline (ex. Message );
}

From the perspective of the entire structure, devexpress's data persistence layer should be quite good. On the one hand, it can greatly simplify developers' coding work, while the Code of data persistence objects is mechanized, you can write a tool.

Simple note!

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.