IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityManager Class : Saved Event |
'Declaration
Public Event Saved As EventHandler(Of EntitySavedEventArgs)
'Usage
Dim instance As EntityManager Dim handler As EventHandler(Of EntitySavedEventArgs) AddHandler instance.Saved, handler
public event EventHandler<EntitySavedEventArgs> Saved
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.
Property | Description |
---|---|
Cancelled | Returns whether the operation was cancelled. (Inherited from IdeaBlade.EntityModel.CompletedEventArgs) |
CompletedSuccessfully | Returns whether the operation completed successfully. (Inherited from IdeaBlade.EntityModel.CompletedEventArgs) |
CompletedSynchronously | Returns whether the operation was completed synchronously. (Inherited from IdeaBlade.EntityModel.CompletedEventArgs) |
Entities | List of entities saved. |
Error | The exception, if any, thrown by the underlying operation. (Inherited from IdeaBlade.EntityModel.CompletedEventArgs) |
HasError | Returns whether the operation failed. (Inherited from IdeaBlade.EntityModel.CompletedEventArgs) |
IsCompleted | Returns whether the operation completed. (Inherited from IdeaBlade.EntityModel.CompletedEventArgs) |
IsErrorHandled | Whether the Error was handled ( if one exists). (Inherited from IdeaBlade.EntityModel.CompletedEventArgs) |
SaveResult | The SaveResult for the operation. |
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; } 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()); } }
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