DevForce Help Reference
SaveChanges Method (EntityManager)
Example 


Options controlling save processing. If not specified the DefaultSaveOptions are used.
Persists all changed entities within the EntityManager cache to the backend data source using the SaveOptions specified.
Syntax
'Declaration
 
Public Sub SaveChanges( _
   Optional ByVal saveOptions As SaveOptions _
) 
'Usage
 
Dim instance As EntityManager
Dim saveOptions As SaveOptions
 
instance.SaveChanges(saveOptions)
public void SaveChanges( 
   SaveOptions saveOptions
)

Parameters

saveOptions
Options controlling save processing. If not specified the DefaultSaveOptions are used.
Exceptions
ExceptionDescription
EntityManagerSaveExceptionThrown for save exceptions not handled by an EntityServerError handler
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 the operation is a no-op, and the cache remains in the same state as before the save was called.

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 
  try {
     mgr.SaveChanges();
  } catch (EntityManagerSaveException ex) {
     MessageBox.Show(ex.Message);
  }
}
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