expressappframework-devexpress-dot-expressapp-dot-baseobjectspace-dot-createobject-1.md
Creates an object of the type designated by the specified generic type parameter.
Namespace : DevExpress.ExpressApp
Assembly : DevExpress.ExpressApp.v25.2.dll
NuGet Package : DevExpress.ExpressApp
public ObjectType CreateObject<ObjectType>()
Public Function CreateObject(Of ObjectType) As ObjectType
| Name |
|---|
| ObjectType |
| Type | Description |
|---|---|
| ObjectType |
A created object of the specified type.
|
This method calls a protected virtual method, CreateObjectCore , which must be overridden in the BaseObjectSpace class descendants. After an object of the specified type is created, the BaseObjectSpace.SetModified method is called so that the object is saved to the database during the next changes commit (see BaseObjectSpace.CommitChanges).
Use this method to create objects in Controllers. In a regular business class, create objects directly via their constructor.
The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateObject<ObjectType>() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
nonPersistentObjectSpace.AdditionalObjectSpaces.Add(persistentObjectSpace);
ViewFilterContainer newViewFilterContainer = nonPersistentObjectSpace.CreateObject<ViewFilterContainer>();
newViewFilterContainer.ObjectType = View.ObjectTypeInfo.Type;
nonPersistentOS.AdditionalObjectSpaces.Add(persistentOS);
var obj = nonPersistentOS.CreateObject<MySearchClass>();
nonPersistentOS.CommitChanges();
See Also