Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.2.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
T

#Returns

Type Description
T

Object type.

#Remarks

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

C#
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