Share via


DataServiceContext.AddObject(String, Object) Method

Definition

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

public virtual void AddObject (string entitySetName, object entity);
abstract member AddObject : string * obj -> unit
override this.AddObject : string * obj -> unit
Public Overridable Sub AddObject (entitySetName As String, entity As Object)

Parameters

entitySetName
String

The name of the entity set to which the resource will be added.

entity
Object

The object to be tracked by the DataServiceContext.

Exceptions

When entitySetName or entity is null.

When entitySetName is empty.-or-When entity does not have a key property defined.

When the entity is already being tracked by the context.

Remarks

It does not follow the object graph and add related objects. Any leading or trailing forward slashes will automatically be trimmed from entitySetName.

Applies to