Skip to main content
All docs
V24.1
.NET 6.0+

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);
        }
    }
}

Tip

Alternatively, you can use the CreateObjectSpace<T>() method.

How to Fix

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