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

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Reference Properties in Domain Components

  • 2 minutes to read

The example below illustrates how to implement Reference (Foreign Key, Complex Type) Properties in a Domain Component interface.

// Displayed in a lookup control:
IReferencedObject LookupReferencedObject { get; set; }
// Displayed in a set of editors. Each editor represents an individual property of the referenced object:
[DevExpress.ExpressApp.DC.AggregatedAttribute, ExpandObjectMembers(ExpandObjectMembers.Always)]
IExpandPropertiesObject ExpandPropertiesObject { get; set; }
// Displayed in a Detail Property Editor that shows a referenced object's Detail View:
[DevExpress.ExpressApp.DC.AggregatedAttribute, EditorAlias(EditorAliases.DetailPropertyEditor)]
[ExpandObjectMembers(ExpandObjectMembers.Never)]
IEmbeddedDetailViewObject EmbeddedDetailViewObject { get; set; }
// Displayed in a button edit that invokes a referenced object's Detail View in a separate modal window:
[DevExpress.ExpressApp.DC.AggregatedAttribute, ExpandObjectMembers(ExpandObjectMembers.Never)]
IPopupDetailViewObject PopupDetailViewObject { get; set; }

If you use Detail Property Editor for a reference property, or apply ExpandObjectMembers attribute to a reference property, it is required to initialize such a property in the when a new parent object is created. Otherwise, the reference property’s fields will be read-only. The initialization should be done in the overridden AfterConstruction method of the attached Domain Logic the following way:

[DomainLogic(typeof(IReferenceProperties))]
public class IReferenceProperties_Logic {
    public void AfterConstruction(IReferenceProperties obj, IObjectSpace objectSpace) {
        obj.EmbeddedDetailViewObject = objectSpace.CreateObject<IEmbeddedDetailViewObject>();
    }
}