แก้ไข

แชร์ผ่าน


DataServiceContext.BeginSaveChanges Method

Definition

Submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

Overloads

BeginSaveChanges(SaveChangesOptions, AsyncCallback, Object)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

BeginSaveChanges(AsyncCallback, Object)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

BeginSaveChanges(SaveChangesOptions, AsyncCallback, Object)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

public:
 IAsyncResult ^ BeginSaveChanges(System::Data::Services::Client::SaveChangesOptions options, AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginSaveChanges (System.Data.Services.Client.SaveChangesOptions options, AsyncCallback callback, object state);
member this.BeginSaveChanges : System.Data.Services.Client.SaveChangesOptions * AsyncCallback * obj -> IAsyncResult
Public Function BeginSaveChanges (options As SaveChangesOptions, callback As AsyncCallback, state As Object) As IAsyncResult

Parameters

options
SaveChangesOptions

The options for how the client can save the pending set of changes.

callback
AsyncCallback

The delegate to call when the operation is completed.

state
Object

The user-defined state object that is used to pass context data to the callback method.

Returns

An IAsyncResult that represents the status of the asynchronous operation.

Remarks

Changes are added to the DataServiceContext by calling the AddObject, AddLink, AttachTo, AttachLink, DeleteObject, DeleteLink, Detach, or DetachLink.

If Batch is set, all pending changes are included in a single change set in a batch and submitted to the data service in a single HTTP request. This requires that the target service supports batching.

If Batch is not set:

  • Changes are sent to the data service such as in the SaveChanges() method: one operation to one HTTP request.

  • The StatusCode is always 200.

  • The Headers property returns an empty collection.

If ContinueOnError is set:

  • If an error occurs processing an operation in a change set, the subsequent operations in the change set will not be tried; however, the data service will continue to process the next change set in the batch.

  • This option cannot be set when Batch is set because when batching is enabled, all operations are positioned in a single change set.

If ContinueOnError is not set:

  • If an error occurs while processing an operation, no additional operations are processed by the data service.

A response is generated telling the client which operations were executed, their results, and what operations were not tried because of the error.

Applies to

BeginSaveChanges(AsyncCallback, Object)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

public:
 IAsyncResult ^ BeginSaveChanges(AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginSaveChanges (AsyncCallback callback, object state);
member this.BeginSaveChanges : AsyncCallback * obj -> IAsyncResult
Public Function BeginSaveChanges (callback As AsyncCallback, state As Object) As IAsyncResult

Parameters

callback
AsyncCallback

The delegate to call when the operation is completed.

state
Object

The user-defined state object that is used to pass context data to the callback method.

Returns

An IAsyncResult that represents the status of the asynchronous operation.

Remarks

Changes are added to the DataServiceContext by calling the AddObject, AddLink, AttachTo, AttachLink, DeleteObject, DeleteLink, Detach, or DetachLink.

Changes are sent to the data service, as with the SaveChanges method, one change operation per HTTP request.

If an error occurs while processing an operation, no additional operations are processed by the data service. Instead, a response is generated telling the client what operations were executed, the results, and which operations were not tried because of an error.

Applies to