DevForce Help Reference
TrySaveChangesAsync 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
 
Public Function TrySaveChangesAsync( _
   Optional ByVal saveOptions As SaveOptions _
) As Task(Of SaveResult)
'Usage
 
Dim instance As EntityManager
Dim saveOptions As SaveOptions
Dim value As Task(Of SaveResult)
 
value = instance.TrySaveChangesAsync(saveOptions)
public Task<SaveResult> TrySaveChangesAsync( 
   SaveOptions saveOptions
)

Parameters

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

Return Value

A SaveResult that contains a boolean indicating the result of the save as well as any error encountered during the save.
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.

A SaveResult is always returned. The SaveResult will indicate if the save was successful, if processing was cancelled, or it an error occurred.

The async 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 EntityQuerySaveInterceptor 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.
  var saveResult = await mgr.TrySaveChangesAsync();
}
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