IObjectSpace.CreateObject(Type) Method

Creates an object of the specified type.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.2.dll


object CreateObject(
    Type type
Function CreateObject(
    type As Type
) As Object


Type Name Description
Type type

A Type object which is the type of the object to be created.


Type Description

An object that represents the created object of the specified type.

Below is an example of using the CreateObject method. Here, objectSpace is the Object Space instance which can be accessed as described in the Ways to Implement Business Logic topic.

Person person = objectSpace.CreateObject(typeof(Person));

If you implement the IObjectSpace interface in the BaseObjectSpace class' descendant, you don't have to override the CreateObject method entirely. The BaseObjectSpace.CreateObject 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