The following code snippet shows Many-to-Many Relationship between DemoTask and Contact business classes objects.
With the code above, necessary intermediate tables and relationships will be generated automatically.
[eXpressApp Framework]
DemoTask Class:
1: Public Class DemoTask
2: Inherits Task
3: Public Sub New(ByVal session As Session)
4: MyBase.New(session)
5: End Sub
6: <Association("Contact-DemoTask", GetType(Contact))> _
7: Public ReadOnly Property Contacts() As XPCollection
8: Get
9: Return GetCollection("Contacts")
10: End Get
11: End Property
12: End Class
13:
14:
- The Association attribute is applied to the XPCollection type Contacts property, representing the collection of associated Contacts.
- The Association attribute is required when setting a relationship between objects
- The GetCollection method is used to return a collection in Contacts property getter implementation.
Contact Class:
1: Public Class Contact
2: Inherits Person
3: '...
4: <Association("Contact-DemoTask", GetType(DemoTask))> _
5: Public ReadOnly Property Tasks() As XPCollection
6: Get
7: Return GetCollection("Tasks")
8: End Get
9: End Property
10: End Class
With the code above, necessary intermediate tables and relationships will be generated automatically.
[eXpressApp Framework]
No comments:
Post a Comment