DevForce Help Reference
TrySaveChanges Method (EntityManager)
Example 


Options controlling save processing. If not specified the DefaultSaveOptions are used.
Persists one or more selected Entities within the EntityManager cache to the backend data source using the SaveOptions specified.
Syntax
'Declaration
 
Public Function TrySaveChanges( _
   Optional ByVal saveOptions As SaveOptions _
) As SaveResult
'Usage
 
Dim instance As EntityManager
Dim saveOptions As SaveOptions
Dim value As SaveResult
 
value = instance.TrySaveChanges(saveOptions)
public SaveResult TrySaveChanges( 
   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.

Example
private void SaveSample() {
  DomainModelEntityManager mgr = new DomainModelEntityManager();
  
  // Retrieve a single Order and its Customer
  OrderSummary order = mgr.ExecuteQuery<OrderSummary>(new entityKey(typeof(OrderSummary), 1));
  Customer cust = order.Customer;

  // Change the address in both Order and Customer
  order.ShipAddress = "100 Broadway";
  cust.Address = "100 Broadway";

  // Now save 
  SaveResult sr = mgr.TrySaveChanges();
  if (sr.Ok) {
    MessageBox.Show("Changes saved to database.");
  } 
}
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
SaveResult Class

Send Feedback