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.

public interface ICustomerBase { }
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");

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