Back to Devexpress

XAF0015: Association must not have the Aggregated attribute if it is paired to the "many" end of the association

expressappframework-403920-debugging-testing-and-error-handling-code-diagnostics-xaf0015.md

latest2.4 KB
Original Source

XAF0015: Association must not have the Aggregated attribute if it is paired to the "many" end of the association

  • Sep 05, 2022
  • 2 minutes to read

Severity: Warning

Many-to-Many associations must not have Aggregated attribute on any ends. One-to-Many associations must not have Aggregated attribute on “one” ends.

Examples

Invalid Code

csharp
using DevExpress.ExpressApp;

namespace MySolution.Module.BusinessObjects { 
    [Persistent]
    public class OneToManyAssociationBothAggregated {
        // One-to-Many association should not have Aggregated attribute on "one" end
        [Association, Aggregated]
        public OneToManyAssociationBothAggregated Parent { 
            get { ... }
            set { ... } 
        }

        [Association, Aggregated]
        public XPCollection<OneToManyAssociationBothAggregated> Children { 
            get { ... } 
        }
    }

    [Persistent]
    public class ManyToManyAssociationBothAggregated {
        // Many-to-Many association should not have Aggregated attribute on any end
        [Association, Aggregated]
        public XPCollection<ManyToManyAssociationBothAggregated> Friends { 
            get { ... }
            set { ... } 
        }

        // Many-to-Many association should not have Aggregated attribute on any end
        [Association, Aggregated]
        public XPCollection<ManyToManyAssociationBothAggregated> Colleagues { 
            get { ... }
            set { ... } 
        }
    }
}

Valid Code

csharp
using DevExpress.ExpressApp;

namespace MySolution.Module.BusinessObjects {
    [Persistent]
    public class OneToOneAssociationBothAggregated : BaseObject {
        [Association, Aggregated]
        public OneToOneAssociationBothAggregated PropertyOne { 
            get { ... }
            set { ... } 
        }

        [Association, Aggregated]
        public OneToOneAssociationBothAggregated PropertyTwo { 
            get { ... }
            set { ... } 
        }
    }

    [Persistent]
    public class OneToManyAssociationManyAggregated : BaseObject {
        [Association]
        public OneToManyAssociationManyAggregated Parent { 
            get { ... }
            set { ... } 
        }

        [Association, Aggregated]
        public XPCollection<OneToManyAssociationManyAggregated> Children { 
            get { ... }
        }
    }
}