I'm looking for the recommended way to ensure that a derived entity is returned by various base entitities in the Adapter scenario. I have an "Address" entity that I've extended to include a "Parse" method and an overriden "ToString" method that returns a formatted version of the complete address.
I've created the necessary inherited entity and factory classes and now I want to make sure that whenever I need to reference this new "MyAddress" entity via other entities, it returns the correct type.
For example, I have a "PurchaseOrder" entity that needs to return 3 of these "MyAddress" entities: BillToAddress, ShipToAddress, and VendorAddress. So, I've extended the generated PurchaseOrder entity and created "MyPurchaseOrder". Do I just copy the code laid out in the generated base class? If so, what do I do about "SetupSyncBillToAddress(value)" which is typed to the base class?:
Public Class MyPurchaseOrderEntity
Inherits PurchaseOrderEntity
Private _billToAddress as MyAddressEntity
...
Public Property BillToAddress as MyAddressEntity
Get
Return _billToAddress
End Get
Set (value as MyAddressEntity)
If MyBase.IsDeserializing Then
SetupSyncBillToAddress(value)
Else
If value Is Nothing Then
If Not _billToAddress Is Nothing Then
_billToAddress.UnsetRelatedEntity(Me, "PurchaseOrder")
End If
Else
CType(value, IEntity2).SetRelatedEntity(Me, "PurchaseOrder")
End If
End If
End Set
End Property
End Class
On a related note, it seems that when setting a related entity such as PurchaseOrder.BillToAddress to NULL, it does not set the related FK to NULL to match. Is this expected behavior? I can't remember if auto-syncing PK/FKs for entities was implemented in Adapter...
Thanks.
Jeff...