ObjectContext.SaveChangesAsync Method

Definition

Overloads

SaveChangesAsync()

Asynchronously persists all updates to the database and resets change tracking in the object context.

SaveChangesAsync(SaveOptions)

Asynchronously persists all updates to the database and optionally resets change tracking in the object context.

SaveChangesAsync(CancellationToken)

Asynchronously persists all updates to the database and resets change tracking in the object context.

SaveChangesAsync(SaveOptions, CancellationToken)

Asynchronously persists all updates to the database and optionally resets change tracking in the object context.

SaveChangesAsync()

Asynchronously persists all updates to the database and resets change tracking in the object context.

public virtual System.Threading.Tasks.Task<int> SaveChangesAsync ();
abstract member SaveChangesAsync : unit -> System.Threading.Tasks.Task<int>
override this.SaveChangesAsync : unit -> System.Threading.Tasks.Task<int>
Public Overridable Function SaveChangesAsync () As Task(Of Integer)

Returns

A task that represents the asynchronous save operation. The task result contains the number of state entries written to the underlying database. This can include state entries for entities and/or relationships. Relationship state entries are created for many-to-many relationships and relationships where there is no foreign key property included in the entity class (often referred to as independent associations).

Exceptions

An optimistic concurrency violation has occurred while saving changes.

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

SaveChangesAsync(SaveOptions)

Asynchronously persists all updates to the database and optionally resets change tracking in the object context.

public virtual System.Threading.Tasks.Task<int> SaveChangesAsync (System.Data.Entity.Core.Objects.SaveOptions options);
abstract member SaveChangesAsync : System.Data.Entity.Core.Objects.SaveOptions -> System.Threading.Tasks.Task<int>
override this.SaveChangesAsync : System.Data.Entity.Core.Objects.SaveOptions -> System.Threading.Tasks.Task<int>
Public Overridable Function SaveChangesAsync (options As SaveOptions) As Task(Of Integer)

Parameters

options
SaveOptions

A SaveOptions value that determines the behavior of the operation.

Returns

A task that represents the asynchronous save operation. The task result contains the number of state entries written to the underlying database. This can include state entries for entities and/or relationships. Relationship state entries are created for many-to-many relationships and relationships where there is no foreign key property included in the entity class (often referred to as independent associations).

Exceptions

An optimistic concurrency violation has occurred while saving changes.

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

SaveChangesAsync(CancellationToken)

Asynchronously persists all updates to the database and resets change tracking in the object context.

public virtual System.Threading.Tasks.Task<int> SaveChangesAsync (System.Threading.CancellationToken cancellationToken);
abstract member SaveChangesAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
override this.SaveChangesAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>

Parameters

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

A task that represents the asynchronous save operation. The task result contains the number of state entries written to the underlying database. This can include state entries for entities and/or relationships. Relationship state entries are created for many-to-many relationships and relationships where there is no foreign key property included in the entity class (often referred to as independent associations).

Exceptions

An optimistic concurrency violation has occurred while saving changes.

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

SaveChangesAsync(SaveOptions, CancellationToken)

Asynchronously persists all updates to the database and optionally resets change tracking in the object context.

public virtual System.Threading.Tasks.Task<int> SaveChangesAsync (System.Data.Entity.Core.Objects.SaveOptions options, System.Threading.CancellationToken cancellationToken);
abstract member SaveChangesAsync : System.Data.Entity.Core.Objects.SaveOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
override this.SaveChangesAsync : System.Data.Entity.Core.Objects.SaveOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>

Parameters

options
SaveOptions

A SaveOptions value that determines the behavior of the operation.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

A task that represents the asynchronous save operation. The task result contains the number of state entries written to the underlying database. This can include state entries for entities and/or relationships. Relationship state entries are created for many-to-many relationships and relationships where there is no foreign key property included in the entity class (often referred to as independent associations).

Exceptions

An optimistic concurrency violation has occurred while saving changes.

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

Applies to