Back to Devexpress

XafApplication.CreateObject<T>(out IObjectSpace) Method

expressappframework-devexpress-dot-expressapp-dot-xafapplication-dot-createobject-1-x28-devexpress-dot-expressapp-dot-iobjectspace-x29.md

latest2.2 KB
Original Source

XafApplication.CreateObject<T>(out IObjectSpace) Method

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

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public T CreateObject<T>(
    out IObjectSpace objectSpace
)
vb
Public Function CreateObject(Of T)(
    ByRef objectSpace As IObjectSpace
) As T

Parameters

NameTypeDescription
objectSpaceIObjectSpace

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

|

Type Parameters

Name
T

Returns

TypeDescription
T

Object type.

|

Remarks

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

csharp
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

XafApplication Class

XafApplication Members

DevExpress.ExpressApp Namespace