Xpo third-party control Learning (devexpress Persistent Object) series-others (Session, transaction, validity check...

Source: Internet
Author: User
V. Session:

Manage database connection information. There is a default connection: MS Access oledb provider. If you use it, you do not have to initialize the session instance in the program. But if you want to use your own connection, there are two ways: one is to change the connection information of the default connection, the other is to create your own, but you must reference it when building a persistent class. The first one is simpler. Unless the application needs to consider connecting two databases

 

 

6. Access to Binary large object fields

Use delayed loading ):

Here, you must specify a private property of the xpdelayedproperty type, and add the attribute, which is a bit tedious in design.

Public Class Customer

Inherits xpobject

'...

Private document as new xpdelayedproperty

<Delayed ("document")> _

Public property attachment () as <byte> ()

Get

Return ctype (document. Value, <byte> ())

End get

Set (byval value as <byte> ())

Document. value = Value

End set

End Property

End Class 'customer

VII. transaction support:

Transactions are indispensable in database programs.

Obviously, this function is provided by the session.

Dim account as new account

Session. defaultsession. begintransaction ()

Try

Account. Amount = Amount

Account. Save ()

Session. defaultsession. committransaction ()

Catch e as exception

Session. defaultsession. rollbacktransaction ()

Account. Reload ()

End try

Note that reload () is used when exception occurs ().

 

 

8. Check the data validity before saving:

Class account

Inherits xpobject

Public amount as double = defaultamount

 

Protected overrides sub beforesave ()

Mybase. beforesave ()

If not isdeleted then

If amount <0 then

Throw new exception ("negative amount ")

End if

End if

End sub 'beforesave

End Class 'account

Note that the isdeleted is determined first.

 

9. concurrent operations:

Provides a check mechanism to check whether the object has changed before modification. In the past, we had to write our own code to check, and now this is also available.

 

10. Data paging Mechanism

For large data volumes, we generally extract data in batches instead of once, reducing memory usage and accelerating extraction. Xpo provides direct support. However, it does not use xpcollection, but uses another class xpcusor. Similar to xpcollection, condition objects are also supported, but multiple pages are supported.

This design concept is puzzling. Why is it not the same?

 

11. Structural persistence support:

Public structure point

<Persistent ("abscissa")> Public X as integer

Public y as integer

End structure 'point

 

Public class shape

Inherits xpobject

Public name as string = ""

<Persistent ("location")> public position as point

End Class 'shape

Note that only the attribute structure can be persistent.

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.