Skip to main content
All docs
V22.1
.NET Framework 4.5.2+

XAF0012: Avoid calling the XafApplication.CreateObjectSpace() method overload without the Type parameter

Severity: Warning

Use XafApplication.CreateObjectSpace() method overload only when your application registers only one XafApplication.ObjectSpaceProvider.

We recommend that you specify the type of objects that a newly created ObjectSpace will support: use the CreateObjectSpace(Type) overload.

Examples

Invalid Code

using DevExpress.ExpressApp;

namespace MySolution.Module.BusinessObjects{ 
    public class TestClass {
        public void TestMethod(XafApplication xafApplication) {
            // Avoid calling the XafApplication.CreateObjectSpace() 
            // method overload without the Type parameter
            //IObjectSpace objectSpace = xafApplication.CreateObjectSpace();
        }
    }
}

Valid Code

using DevExpress.ExpressApp;

namespace MySolution.Module.BusinessObjects {
    // ...
    public class TestClass {
        public void TestMethod(XafApplication xafApplication) {
            Type objectType = typeof(Person);
            // This code meets the requirements
            IObjectSpace objectSpace = xafApplication.CreateObjectSpace(objectType);
        }
    }
}

How to Fix

Call the XafApplication.CreateObjectSpace(Type) method with a specified Type parameter.