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



entities
List of IEntity objects to be persisted
saveOptions
Options controlling save processing
Persists one or more selected Entities within the EntityManager cache to the backend data source using the SaveOptions specified.

Syntax

Visual Basic (Declaration) 
Public Overloads Function SaveChanges( _
   ByVal entities As IEnumerable, _
   Optional ByVal saveOptions As SaveOptions _
) As SaveResult
Visual Basic (Usage)Copy Code
Dim instance As EntityManager
Dim entities As IEnumerable
Dim saveOptions As SaveOptions
Dim value As SaveResult
 
value = instance.SaveChanges(entities, saveOptions)
C# 
public SaveResult SaveChanges( 
   IEnumerable entities,
   SaveOptions saveOptions
)
C++/CLI 
public:
SaveResult^ SaveChanges( 
   IEnumerable^ entities,
   SaveOptions^ saveOptions
) 

Parameters

entities
List of IEntity objects to be persisted
saveOptions
Options controlling save processing

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 the specified entities to the backend data source. Upon success, AcceptChanges will have been called and all entities will return to an Unchanged state.

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.

If you are saving only a single entity, an easy way of calling this method is to create a new one-item array, similar to the following example:

            C#:  pm.SaveChanges(new Employee[] { myEmployee });
            VB:  pm.SaveChanges(New Employee() {myEmployee})
            

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.