IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityManager Class : TrySaveChangesAsync Method |
'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 )
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.
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(); }
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