ObjectContext.SaveChangesAsync Method
Asynchronously persists all updates to the store.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() | SaveChangesAsync() | Asynchronously persists all updates to the database and 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) | Asynchronously persists all updates to the database and optionally 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. |
ObjectContext.SaveChangesAsync Method ()
Asynchronously persists all updates to the database and resets change tracking in the object context.
Return Value
Type: System.Threading.Tasks.Task<Int32>A task that represents the asynchronous operation. The task result contains the number of objects in an Added, Modified, or Deleted state when SaveChanges was called.
Exception | Condition |
---|---|
OptimisticConcurrencyException | An optimistic concurrency violation has occurred while saving changes. |
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.
ObjectContext.SaveChangesAsync Method (CancellationToken)
Asynchronously persists all updates to the database and resets change tracking in the object context.
Parameters
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<Int32>A task that represents the asynchronous operation. The task result contains the number of objects in an Added, Modified, or Deleted state when SaveChanges was called.
Exception | Condition |
---|---|
OptimisticConcurrencyException | An optimistic concurrency violation has occurred while saving changes. |
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.
ObjectContext.SaveChangesAsync Method (SaveOptions)
Asynchronously persists all updates to the database and optionally resets change tracking in the object context.
Parameters
- options
-
Type:
System.Data.Entity.Core.Objects.SaveOptions
A SaveOptions value that determines the behavior of the operation.
Return Value
Type: System.Threading.Tasks.Task<Int32>A task that represents the asynchronous operation. The task result contains the number of objects in an Added, Modified, or Deleted state when SaveChanges was called.
Exception | Condition |
---|---|
OptimisticConcurrencyException | An optimistic concurrency violation has occurred while saving changes. |
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.
ObjectContext.SaveChangesAsync Method (SaveOptions, CancellationToken)
Asynchronously persists all updates to the database and optionally resets change tracking in the object context.
public virtual Task<int> SaveChangesAsync( SaveOptions options, CancellationToken cancellationToken )
Parameters
- options
-
Type:
System.Data.Entity.Core.Objects.SaveOptions
A SaveOptions value that determines the behavior of the operation.
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<Int32>A task that represents the asynchronous operation. The task result contains the number of objects in an Added, Modified, or Deleted state when SaveChanges was called.
Exception | Condition |
---|---|
OptimisticConcurrencyException | An optimistic concurrency violation has occurred while saving changes. |
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.