Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.