ObjectContext.SaveChangesAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
Applies to
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.
Applies to
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.
Applies to
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
Entity Framework