DevForce Help Reference
SaveChangesAsync Method (EntityManager)
Example 


Options controlling save processing. If not specified the DefaultSaveOptions are used.
Perform an asynchronous SaveChanges operation with the specified SaveOptions.
Syntax
'Declaration
 
<AsyncStateMachineAttribute(IdeaBlade.EntityModel.EntityManager+d__152)> 
Public Function SaveChangesAsync( _ 
   Optional ByVal saveOptions As SaveOptions _ 
) As Task
'Usage
 
Dim instance As EntityManager
Dim saveOptions As SaveOptions
Dim value As Task
 
value = instance.SaveChangesAsync(saveOptions)
[AsyncStateMachine(IdeaBlade.EntityModel.EntityManager+d__152)] 
public Task SaveChangesAsync( 
   SaveOptions saveOptions 
)

Parameters

saveOptions
Options controlling save processing. If not specified the DefaultSaveOptions are used.

Return Value

A System.Threading.Tasks.Task which will indicate whether the asynchronous save concluded successfully.
Exceptions
ExceptionDescription
EntityManagerSaveExceptionThrown for save exceptions not handled by an EntityServerError handler
System.OperationCanceledExceptionThrown if the save was cancelled
Remarks
Persists all additions, modifications and deletions within the EntityManager cache to the backend data source. Upon success, all entities will be in an Unchanged state.

If the save fails an EntityManagerSaveException will be thrown.

If the save is cancelled an System.OperationCanceledException will be thrown.

The asynchronous save task itself cannot be cancelled. However, you can cancel the save process on the client before the save starts in a Saving event handler. You can also cancel the save process on the server in an EntityServerSaveInterceptor prior to executing the save to the data source.

Example
public async void AsyncSaveSimple() {
  DomainModelEntityManager mgr = new DomainModelEntityManager();

  Customer c1 = new Customer() { CompanyName = "Toys R Us" };
  mgr.AddEntity(c1);
  Customer c2 = new Customer() { CompanyName = "Apple" };
  mgr.AddEntity(c2);

  // Save all modified entities using default SaveOptions.
  await mgr.SaveChangesAsync();
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntityManager Class
EntityManager Members

Send Feedback