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.

XAF0001: Implement XPO business class constructors correctly

Severity: Error

XAF requires that the XPO business object’s constructor should:

Violation of these rules may lead to unexpected results. For example, the New Action may be hidden for this object.

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

Examples

Invalid Code

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

namespace MySolution.Module.BusinessObjects{ 
    [DefaultClassOptions] 
    public class ExampleObject1 : BaseObject {
        // The constructor must be public
        // ExampleObject1(Session session) : base(session) {} // Error: XAF0001
    } 
    // ...

    [DefaultClassOptions] 
    public class ExampleObject2 : BaseObject {  
        // The constructor must take a Session object as a parameter
        // public ExampleObject2(){} // Error: XAF0001
    } 
    // ...

    [DefaultClassOptions] 
    public class ExampleObject3 : BaseObject {  
        // The constructor must pass a Session object 
        // as an argument to the base class constructor. 
        // public ExampleObject3(Session session){} // Error: XAF0001
    } 
    // ...
}

Valid Code

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

namespace MySolution.Module.BusinessObjects{ 
    [DefaultClassOptions] 
    public class ExampleObject1 : BaseObject {
        // This constructor meets the requirements
        public ExampleObject1(Session session) : base(session) {} 
    } 
    // ...
}