Upcasting

Important

Domain Component (DC) interfaces are abstractions above eXpress Persistent Objects (XPO) classes. Notwithstanding its benefits, this abstraction imposes certain technical limitations. DC is only suitable for certain usage scenarios. Mobile and SPA User Interfaces are not supported for DC. DC is in maintenance mode and we do not recommend its use in new software projects.

When using the Upcasting feature with Domain Component entities, note that you must cast to the entity name, and not the corresponding Domain Component interface. Consider the following code snippet.

[DomainComponent]
public interface ICustomerBase { }
//...
[DomainComponent]
public interface ICustomer : ICustomerBase { }
//...
XafTypesInfo.Instance.RegisterEntity("Contact", typeof(ICustomer));

Here, the ICustomer Domain Component is registered as a Contact entity. When performing upcasting in the context of the ICustomerBase Domain Component, you must cast to Contact and not to ICustomer.

CriteriaOperator customerBaseUpcastingFilter = 
    CriteriaOperator.Parse("<Contact>ExtendedProperty > 0");
Note

Upcasting is not supported and an InvalidPropertyPathException can be thrown for Domain Components if generated XPO classes do not form the same inheritance chain as their source DC interface definitions (a generated class corresponding to a child/descendant DC interface is not assignable/inherited from a class corresponding to the parent/base DC interface). This includes all scenarios with Shared Parts registered using the ITypesInfo.RegisterSharedPart method and certain complex scenarios with regular domain components registered via the ITypesInfo.RegisterEntity method.

See Also