XafApplication.CreateObject<T>(out IObjectSpace) Method
In This Article
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 |
---|---|---|
object |
IObject |
A variable that stores the IObject |
#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