Skip to main content

Create

info

This documentation page is heavily under construction. Various information may be missing. Please report any feedback here.

When working with Cognibase in a client context, there are multiple ways to create a DataItem and attach it to the Component Object Model (COM). Below are two recommended approaches:

1. Using the createDataItem Method

This is a straightforward method for quickly creating and attaching a data item:

_client.CreateDataItem<MyDataItem>();

In this example, a new MyDataItem data item is created and attached to the COM.

2. Using the ObjMgrProvider Context

This approach allows you to create and manipulate DataItem objects within a specific client context:

using (new ObjMgrProvider(client))
{
// Create item in the client context
var item = new MyDataItem() { name = "myItem" };
}

Within the ObjMgrProvider context, any object creation with the standard new keyword is created within the context of the COM instance that is provided as parameter to the ObjMgrProvider.