XAF0012: Avoid calling the XafApplication.CreateObjectSpace() method overload without the Type parameter
Severity: Warning
Use the XafApplication.CreateObjectSpace() overload only when your application registers a single Object Space Provider.
Specify the type of objects that a newly created Object Space supports with 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.