Skip to main content
All docs
V24.1
.NET 6.0+

XafApplication.CreateObject<T>(out IObjectSpace) Method

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

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public T CreateObject<T>(
    out IObjectSpace objectSpace
)

Parameters

Name Type Description
objectSpace IObjectSpace

A variable that stores the IObjectSpace used to create the intended object.

Type Parameters

Name Description
T

Object type.

Returns

Type Description
T

A created object of the specified type.

Remarks

The following code demonstrates how to implement a Simple Action that creates a new object of the specified type:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using dxTestSolution.Module.BusinessObjects;

public class CustomWinController : ViewController {
    public CustomWinController() {
        var myAction1 = new SimpleAction(this, "MyWinAction1", PredefinedCategory.Edit);
        myAction1.Execute += MyAction1_Execute;
    }

    private void MyAction1_Execute(object sender, SimpleActionExecuteEventArgs e) {
        var newContact = Application.CreateObject<Contact>(out IObjectSpace createdOS);
        newContact.FirstName = "contactName";
        createdOS.CommitChanges();
    }
}
See Also