Adds the TData instance to the default C1 storage. If the storage does not exist, then one is created. This method triggers the events OnBeforeAdd and OnAfterAdd for the item item.

Namespace: Composite.Data
Assembly: Composite (in Composite.dll) Version: 6.1.6325.31818

Syntax

C#
public TData Add<TData>(
	TData item
)
where TData : class, IData
Visual Basic
Public Function Add(Of TData As {Class, IData}) ( _
	item As TData _
) As TData
Visual C++
public:
generic<typename TData>
where TData : ref class, IData
TData Add(
	TData item
)

Parameters

item
Type: TData
The data item to add

Type Parameters

TData
An IData interface

Return Value

The newly added data item. Note: This could differ from the item

Examples

CopyC#
using (DataConnection connection = new DataConnection())
{
   IMyDataType myDataType = DataConnection.New<IMyDataType>();
   myDataType.Name = "John Doe";
   myDataType = connection.Add<IMyDataType>(myDataType); 

   // Note that the reassigned of myDataType is important here
   // if its used for an later update.

   myDataType.Name = "Jane Doe";
   connection.Update<IMyDataType>(myDataType);
}

See Also