IdeaBlade DevForce 2010 Help Reference
SaveChanges() Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityManager Class > SaveChanges Method : SaveChanges() Method



Persists all changed IEntity objects within the EntityManager cache to the backend data source using the DefaultSaveOptions.

Syntax

Visual Basic (Declaration) 
Public Overloads Function SaveChanges() As SaveResult
Visual Basic (Usage)Copy Code
Dim instance As EntityManager
Dim value As SaveResult
 
value = instance.SaveChanges()
C# 
public SaveResult SaveChanges()
C++/CLI 
public:
SaveResult^ SaveChanges(); 

Return Value

A SaveResult object that contains a boolean indicating the result of the save as well as any errors encountered during the save.

Exceptions

Example

C#Copy Code
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 -- using a save list and SaveOptions.
  List<Entity> changedEntities = new List<Entity>();
  changedEntities.Add(order);
  changedEntities.Add(cust);
  SaveOptions options = new SaveOptions();

  SaveResult sr = mgr.SaveChanges(changedEntities, options);
  if (sr.Ok) {
    MessageBox.Show("Changes saved to database.");
  } 
}

Remarks

Persists all additions, modifications and deletions within the EntityManager cache to the backend data source. Upon success, System.Data.DataSet.AcceptChanges will have been called.

A SaveResult is always returned if no errors occurred during save processing, if processing was cancelled, or if the error was handled by the EntityServerError event handler.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.