All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Standard 2.0+
.NET Framework 4.5.2+
The page you are viewing does not exist in the .NET Framework 4.5.2+ platform documentation. This link will take you to the parent topic of the current section.
.NET Standard 2.0+
.NET Core 3.0+

EFCoreObjectSpace.CreateObject(Type) Method

Creates an object of the specified type.

Namespace: DevExpress.ExpressApp.EFCore

Assembly: DevExpress.ExpressApp.EFCore.v21.1.dll

Declaration

public override object CreateObject(
    Type objectType
)

Parameters

Name Type Description
objectType Type

The type of the object to be created.

Returns

Type Description
Object

A created object of the specified type.

Remarks

This method calls the CreateObject(Type) method and throws an exception if the specified type is not registered.

The following example shows how to use this method:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.EFCore;
using DevExpress.Persistent.Base;
// ...
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 (EFCoreObjectSpace objectSpace = (EFCoreObjectSpace)Application.CreateObjectSpace(typeof(Department))) {
            Department department = (Department)objectSpace.CreateObject(typeof(Department));
            department.Title = e.ParameterCurrentValue as string;
            objectSpace.CommitChanges();
        }
        View.Refresh();
    }
}
See Also