Export (0) Print
Expand All

DataServiceContext.AddObject Method

Adds the specified object to the set of objects that the DataServiceContext is tracking.

Namespace:  System.Data.Services.Client
Assembly:  System.Data.Services.Client (in System.Data.Services.Client.dll)

'Declaration
Public Sub AddObject ( _
	entitySetName As String, _
	entity As Object _
)

Parameters

entitySetName
Type: System.String
The name of the entity set to which the resource will be added.
entity
Type: System.Object
The object to be tracked by the DataServiceContext.

ExceptionCondition
ArgumentNullException

When entitySetName or entity is null.

ArgumentException

When entitySetName is empty.

-or-

When entity does not have a key property defined.

InvalidOperationException

When the entity is already being tracked by the context.

The object is put into the tracking set of the DataServiceContext in the Added state. The DataServiceContext will try to insert the object by HTTP POST on the next call to SaveChanges. This method does not add objects related to the specified entity to the DataServiceContext. Each object must be added through a separate call to AddObject.

The method does not validate that the entity set specified is in the data service associated with the DataServiceContext or that the added object has the required properties needed to be added to the specified entity set.

.NET Framework

Supported in: 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft