All docs
V21.2
21.2 (EAP/Beta)
21.1
The page you are viewing does not exist in version 21.1. This link will take you to the root page.
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
You are viewing help content for pre-release software. This document and the features it describes are subject to change.

XAF0002: XPO business class properties should not be overridden

  • 2 minutes to read

Severity: Error

XAF and XPO do not support the following business object’s properties:

  • Declared with the new keyword.
  • Overridden and virtual properties.

For more information about these requirements, see the following article: Can I override properties of business objects?.

This diagnostic works only for XPO classes derived from the DevExpress.Xpo.PersistentBase class.

Examples

Invalid Code

using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;

namespace MySolution.Module.BusinessObjects {
    public class TestClass : TestClassBase {
        public TestClass(Session session) : base(session) { }

        private int testProperty1;
        // The property must not be virtual
        //public virtual int TestProperty1 { // Error: XAF0002
        //    get { return testProperty1; }
        //    set { SetPropertyValue(nameof(TestProperty1), ref testProperty1, value); }
        //}

        private int testProperty2; 
        // The property must not override a property from a base class
        //public override int TestProperty2 { // Error: XAF0002
        //    get { return testProperty2 + 1; }
        //    set { SetPropertyValue(nameof(TestProperty2), ref testProperty2, value); }
        //}

        private int testProperty3; 
        // The property must not be declared with the `new` keyword
        //public new int TestProperty3 { // Error: XAF0002
        //    get { return testProperty3 + 1; }
        //    set { SetPropertyValue(nameof(TestProperty3), ref testProperty3, value); }
        //}
    }
}

Valid Code

using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;

namespace MySolution.Module.BusinessObjects {
    public class TestClass : TestClassBase {
        public TestClass(Session session) : base(session) { }

        private int testProperty;
        // The property that meets the requirements
        public int TestProperty { 
            get { return testProperty; }
            set { SetPropertyValue(nameof(TestProperty), ref testProperty, value); }
        }
    }
}

How to Fix

Check the business object’s property declaration and ensure the property is declared without the following modifiers:

  • virtual
  • override
  • new