Skip to main content
A newer version of this page is available.
All docs
V18.2

Upcasting

  • 2 minutes to read

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. The Blazor User Interface is not supported for DC. DC is in maintenance mode and we do not recommend its use in new software projects. We recommend that you migrate DC interfaces to pure XPO classes.

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