Skip to main content
.NET Framework 4.5.2+

ExpandObjectMembersAttribute Class

Specifies whether the target reference property is displayed via several Property Editors representing the referenced object’s properties or via a single Lookup or Object Property Editor.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface, Inherited = true)]
public class ExpandObjectMembersAttribute :
    Attribute

Remarks

XAF can visualize a reference property in two ways. The first way is to display a non-aggregated property via a Lookup Property Editor to allow you to choose the property value by selecting one of the existing objects of the corresponding type; aggregated properties are displayed via an Object Property Editor. The second way is to display several Property Editors representing the referenced object’s properties. This way you can customize the referenced object’s property values, but you cannot change the reference property value by choosing another object since the Property Editor for the reference property is not displayed.

By default, non-aggregated reference properties are visualized via a Lookup Property Editor. Aggregated reference properties are visualized via several Property Editors representing the referenced object’s properties. When the default behavior does not suit your needs, decorate a reference property with ExpandObjectMembersAttribute. Specify how the property must be displayed via the expandingMode parameter in the attribute constructor. There are four possible parameter values. The following example demonstrates their use. Suppose you have the Contact class that exposes the Address reference property of the Address type.

[DefaultClassOptions]
public class Contact : BaseObject {
    public virtual string Name { get; set; }
    public virtual Address Address { get; set; }
}

[DefaultClassOptions, DefaultProperty(nameof(StreetAddress))]
public class Address : BaseObject {
    public virtual string StreetAddress { get; set; }
    public virtual string Phone { get; set; }
}

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

If you decorate the Contact.Address property with ExpandObjectMembersAttribute, here is how Contact Views will be affected.

  • ExpandObjectMembers.Always

    [ExpandObjectMembers(ExpandObjectMembers.Always)]
    public virtual Address Address { 
    

    The Contact.Name property is displayed alongside the properties declared in the Address class. You cannot assign another object to the Contact.Address property via this UI. All you can do is change the assigned Address object’s property values.

    ExpandObjectMemebers.Always

  • ExpandObjectMembers.Never

    [ExpandObjectMembers(ExpandObjectMembers.Never)]
    public virtual Address Address { 
    

    The Contact.Name property is displayed alongside the Contact.Address Lookup Property Editor. You can assign another object to the Contact.Address property via this Lookup Property Editor. You cannot directly modify the assigned Address object’s property values.

    ExpandObjectMemebers.Never

  • ExpandObjectMembers.InDetailView

    [ExpandObjectMembers(ExpandObjectMembers.InDetailView)]
    public virtual Address Address { 
    

    The Contact.Name property is displayed alongside the Contact.Address Lookup Property Editor in List Views. In Detail Views, the Contact.Name property is displayed alongside the properties declared in the Address class.

    ExpandObjectMemebers.InDetailView

  • ExpandObjectMembers.InListView

    [ExpandObjectMembers(ExpandObjectMembers.InListView)]
    public virtual Address Address {
    

    The Contact.Name property is displayed alongside the properties declared in the Address class in List Views. In Detail Views, a Lookup Property Editor is used to represent the Contact.Address property.

    ExpandObjectMemebers.InListView

Inheritance

Object
Attribute
ExpandObjectMembersAttribute
See Also