.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET 5.0+

IObjectSpace.CreateObject<ObjectType>() Method

Creates an object of the type designated by the specified generic type parameter.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v21.2.dll


ObjectType CreateObject<ObjectType>()

Type Parameters



Type Description

A created object of the specified type.


The following example uses a Parametrized Action to create a new Department object and refresh the Detail View. The new department becomes available in the Contact.Department Lookup List View.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using MainDemo.Module.BusinessObjects;
// ...
public class AddDepartmentController : ObjectViewController<DetailView, Contact> {
    public AddDepartmentController() {
        ParametrizedAction addDepartmentAction = new ParametrizedAction(this, "AddDepartment", PredefinedCategory.Edit, typeof(string));
        addDepartmentAction.Execute += AddDepartmentAction_Execute;
    private void AddDepartmentAction_Execute(object sender, ParametrizedActionExecuteEventArgs e) {
        using(IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Department))) {
            Department department = objectSpace.CreateObject<Department>();
            department.Title = e.ParameterCurrentValue as string;

If you implement the IObjectSpace interface in the BaseObjectSpace class’ descendant, you don’t have to override the CreateObject<ObjectType> method entirely. The BaseObjectSpace.CreateObject<ObjectType> method invokes a protected virtual BaseObjectSpace.CreateObjectCore method and then sets the returned object modified by calling the BaseObjectSpace.SetModified method for it. So, you should only override the CreateObjectCore method.

The created object will be saved to the database when calling the IObjectSpace.CommitChanges method.

See Also