DataServiceContext.AttachTo Método

Definição

Notifica o DataServiceContext para iniciar o acompanhamento do recurso especificado e fornece o local do recurso no conjunto de recursos especificado.Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource in the specified resource set.

Sobrecargas

AttachTo(String, Object)

Notifica o DataServiceContext para iniciar o acompanhamento do recurso especificado e fornece o local do recurso no conjunto de recursos especificado.Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource within the specified resource set.

AttachTo(String, Object, String)

Notifica o DataServiceContext para iniciar o acompanhamento do recurso especificado e fornece o local do recurso no conjunto de recursos especificado.Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource in the specified resource set.

AttachTo(String, Object)

Notifica o DataServiceContext para iniciar o acompanhamento do recurso especificado e fornece o local do recurso no conjunto de recursos especificado.Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource within the specified resource set.

public:
 void AttachTo(System::String ^ entitySetName, System::Object ^ entity);
public void AttachTo (string entitySetName, object entity);
member this.AttachTo : string * obj -> unit
Public Sub AttachTo (entitySetName As String, entity As Object)

Parâmetros

entitySetName
String

O nome do conjunto que contém o recurso.The name of the set that contains the resource.

entity
Object

O recurso a ser acompanhado pelo DataServiceContext.The resource to be tracked by the DataServiceContext. O recurso está anexado no estado Inalterado.The resource is attached in the Unchanged state.

Exceções

Quando entity ou entitySetName é null.When entity or entitySetName is null.

Quando entitySetName é uma cadeia de caracteres vazia.When entitySetName is an empty string.

- ou --or- Quando a entity não tem uma propriedade de chave definida.When the entity does not have a key property defined.

Quando a entity já está sendo acompanhada pelo contexto.When the entity is already being tracked by the context.

Comentários

Se a entidade fizer parte de um grafo de objeto, essa operação não percorrerá o grafo para adicionar objetos relacionados.If the entity is part of an object graph, this operation does not traverse the graph to add related objects. É uma operação superficial.It is a shallow operation.

O método não valida se o conjunto de entidades especificado ocorre no serviço de dados associado ao DataServiceContext .The method does not validate whether the specified entity set occurs in the data service associated with the DataServiceContext.

Aplica-se a

AttachTo(String, Object, String)

Notifica o DataServiceContext para iniciar o acompanhamento do recurso especificado e fornece o local do recurso no conjunto de recursos especificado.Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource in the specified resource set.

public:
 void AttachTo(System::String ^ entitySetName, System::Object ^ entity, System::String ^ etag);
public void AttachTo (string entitySetName, object entity, string etag);
member this.AttachTo : string * obj * string -> unit
Public Sub AttachTo (entitySetName As String, entity As Object, etag As String)

Parâmetros

entitySetName
String

O valor de cadeia de caracteres que contém o nome do conjunto de entidades ao qual a entidade está anexada.The string value that contains the name of the entity set to which to the entity is attached.

entity
Object

A entidade a ser adicionada.The entity to add.

etag
String

Um valor de Etag que representa o estado da entidade na última vez que ela foi recuperada do serviço de dados.An etag value that represents the state of the entity the last time it was retrieved from the data service. Esse valor é tratado como uma cadeia de caracteres opaca; nenhuma validação é executada pela biblioteca de cliente.This value is treated as an opaque string; no validation is performed on it by the client library.

Exceções

Quando entitySetName é null.When entitySetName is null.

- ou --or- Quando entity é null.When entity is null.

Quando entitySetName é uma cadeia de caracteres vazia.When entitySetName is an empty string.

- ou --or- Quando o objeto fornecido não tem uma propriedade de chave.When the supplied object does not have a key property.

Quando o objeto fornecido já está sendo acompanhado pelo contextoWhen the supplied object is already being tracked by the context

Comentários

Chamar esse método notifica o DataServiceContext para iniciar o rastreamento da entidade especificada e identifica o conjunto de entidades ao qual a entidade pertence.Calling this method notifies the DataServiceContext to start tracking the specified entity and identifies the entity set to which the entity belongs.

Se a entidade fizer parte de um grafo de objeto, essa operação não percorrerá o grafo para adicionar objetos relacionados.If the entity is part of an object graph, this operation does not traverse the graph to add related objects. O objeto é adicionado ao DataServiceContext no estado inalterado.The object is added to the DataServiceContext in the unchanged state. O método não valida se o conjunto de entidades especificado ocorre no serviço de dados associado ao DataServiceContext .The method does not validate whether the entity set specified occurs in the data service associated with the DataServiceContext.

Se a sobrecarga com uma etag for usada, a ETag especificada será associada à entidade anexada recentemente.If the overload with an etag is used, the specified etag is associated with the newly attached entity. A ETag é enviada para o serviço de dados, com todas as operações de atualização ou consulta subsequentes para a entidade, de acordo com a semântica HTTP.The etag is then sent to the data service, with all subsequent update or query operations for the entity, according to HTTP semantics. A geração manual de valores de eTag não é recomendada, mas essa sobrecarga é fornecida para habilitar entidades que podem ter sido serializadas e armazenadas para serem reanexadas junto com metadados de simultaneidade relevantes.Manual generation of etag values is not recommended, but this overload is provided to enable entities that may have been serialized and stored to be reattached together with relevant concurrency metadata.

Aplica-se a