Xpo third-party control Learning (devexpress Persistent Object) series-inheritance and Polymorphism

Source: Internet
Author: User

To some extent, it can be called the relationship between tables.

The persistent classes of xpo support complete inheritance and polymorphism.

For example, a manager is an employee, but an employee is not necessarily a manager. In the previous database design, we can add a management personnel identifier in the employee table, or create another management personnel table, and then use the foreign key to establish a relationship with the employee table.

In xpo, you can use OO to describe the relationship: Create an employee class, and then create a subclass of the employee class: Administrator class.

Public class employee

Inherits xpobject

Public lastname as string = ""

Public firstname as string = ""

<Association ("manageremployees")> Public Manager as manager = nothing

 

Public sub new ()

End sub 'new

 

Public sub new (byval newlastname as string, byval newfirstname as string)

Lastname = newlastname

Firstname = newfirstname

End sub 'new

End Class 'employee

_

 

Public class Manager

Inherits employee

<Association ("manageremployees", GetType (employee)> _

Public readonly property employees () as xpcollection

Get

Return getcollection ("employees ")

End get

End Property

 

Public sub new ()

End sub 'new

 

Public sub new (byval newlastname as string, byval newfirstname as string)

Mybase. New (newlastname, newfirstname)

End sub 'new

End Class 'manager

Note that the association attribute is used. However, the association here only indicates the subordinate employees (Management Personnel) managed by a manager ).

 

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.