IdeaBlade DevForce 2010 Help Reference
Saved Event
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityManager Class : Saved Event



Occurs after the EntityManager has persisted changed entities.

Syntax

Visual Basic (Declaration) 
Public Event Saved As EventHandler(Of EntitySavedEventArgs)
Visual Basic (Usage)Copy Code
Dim instance As EntityManager
Dim handler As EventHandler(Of EntitySavedEventArgs)
 
AddHandler instance.Saved, handler
C# 
public event EventHandler<EntitySavedEventArgs> Saved
C++/CLI 
public:
event EventHandler<EntitySavedEventArgs^>^ Saved

Event Data

The event handler receives an argument of type EntitySavedEventArgs containing data related to this event. The following EntitySavedEventArgs properties provide information specific to this event.

PropertyDescription
Cancelled (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Returns whether the operation was cancelled.
CompletedSuccessfully (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Returns whether the operation completed successfully.
CompletedSynchronously (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Returns whether the operation was completed synchronously.
Entities List of entities saved.
Error (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) The exception, if any, thrown by the underlying operation.
Exception  
HasError (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Returns whether the operation failed.
IsCompleted (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Returns whether the operation completed.
IsErrorHandled (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Whether the Error was handled ( if one exists).
IsUnavailable (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Internal use only.
SaveResult The SaveResult for the operation.
UserState (Inherited from IdeaBlade.EntityModel.AsyncEventArgs) Uniquely identifies the asynchronous operation.

Example

C#Copy Code
public void EntityManager_EventSample() {

  var mgr = new DomainModelEntityManager();
  // Setup some handlers.
  mgr.Querying += QueryingHandler;
  mgr.Fetching += FetchingHandler;
  mgr.Queried += QueriedHandler;
  mgr.Saving += SavingHandler;
  mgr.Saved += SavedHandler;

  // Now try some fetches and saves.

  var orders = mgr.OrderSummaries
    .Where(o => o.Customer.Id == 1)
    .Include("Customer")
    .Include("OrderDetails").ToList();
  DebugFns.WriteLine("Order count = " + orders.Count.ToString());

  // Change the first order and its details.
  OrderSummary anOrder = orders[0];
  anOrder.Freight = 200;
  foreach (OrderDetail dtl in anOrder.OrderDetails) {
    dtl.Discount = .05F;
  }
  SaveResult sr = mgr.SaveChanges();
}

void QueryingHandler(object sender, EntityQueryingEventArgs e) {
  DebugFns.WriteLine("Querying " + e.Query.ToString());
}

void FetchingHandler(object sender, EntityFetchingEventArgs e) {
  DebugFns.WriteLine("Fetching " + e.Query.ToString());
}

void QueriedHandler(object sender, EntityQueriedEventArgs e) {
  DebugFns.WriteLine("Queried " + e.Query.ToString());
  foreach (Entity anEntity in e.Results) {
    DebugFns.WriteLine("Queried - " + anEntity.EntityKey.ToString());
  }
}

void SavingHandler(object sender, EntitySavingEventArgs e) {
  foreach (Entity anEntity in e.Entities) {
    DebugFns.WriteLine("Saving - " + anEntity.EntityKey.ToString() + " - " + anEntity.EntityState.ToString());
  }
}
void SavedHandler(object sender, EntitySavedEventArgs e) {
  foreach (Entity anEntity in e.Entities) {
    DebugFns.WriteLine("Saved - " + anEntity.EntityKey.ToString());
  }
}

Remarks

The EntitySavedEventArgs.Entities list contains the entities saved to the data source. See the DevForce Developer's Guide for more information on the life cycle of a save.

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.